I can not see starwidget in my yii2, I installed the widget, but it doesn't display stars.
See loading gif:
Following is my code:
echo '<label class="control-label">Rating</label>';
echo StarRating::widget([
'name' => 'rating_2',
'value' => 2.5,
'disabled' => true
]);
Is there an explanation to this. Please help!?
Check your js assets. Check if jQuery is not loading twice.
Related
As the title said, I want in some case to hide or disable the breadcrumbs in my Yii2 app.
Is there any general solution or should I put code in any of my view?
I eventually find this solution :
First add a param in the app config/params.php : 'ariane'
return [
'adminEmail' => 'admin#example.com',
'bsVersion' => '3.x',
'ariane' => false,
];
then add code to empty the links array conditionally in the layout main.php:
<?php
if(isset(Yii::$app->params['ariane']) && Yii::$app->params['ariane'] == false){
$this->params['breadcrumbs'] = [];
}
?>
Why not to put breadcrumb in layout and check it for condition only once.
I mean this way in layout file:
<?php if ($condition) {
Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]);
} ?>
<?= $content ?> //view file content
The export dropdown and toggle dropdown do not appear on click. I can't see any errors in console of developer tool.
I have used exactly same code in another project and that seems to work, the only difference is in the column set.
<?php
$exportColumns=[
'name',
'email',
'username',
];
echo ExportMenu::widget([
'dataProvider' => $dataProvider,
'columns' =>$exportColumns,
'dropdownOptions' => [
'label' => 'Export All',
'class' => 'btn btn-secondary'
]
]);
?>
I had a similar issue with my own Yii2 project. In my project the dropdown menu worked, but the buttons that appeared were unresponsive and the entire page froze without any console error.
My own mistake was that I required two bootstrap versions in my composer.json (I left in yiisoft/yii2-bootstrap in my case, removed the other).
Double Bootstrap
It was working perfectly, I have changed nothing, and I have realized that my AutoComplete widget is showing up not there where it was before (it was in the gridView, right underneath the filter textinput where it is expected). Now it shows up in the left upper corner of the page, with the first 2-3 options covered by the navbar. Is there a change in AutoComplete, or in Yii2 now? I have found an option appendTo that has maybe something to do with the problem, and I have done experiments with it but no luck, either it doesn't show up, or still on the wrong place. I have found nothing else relevant.
Here is my code in the gridview:
[
'attribute' => 'name',
'contentOptions' => ['nowrap' => 'nowrap'],
'filter' => AutoComplete::widget([
'model' => $searchModel,
'attribute' => 'name',
'clientOptions' => [
'source' => Pl::find()->allAutoCompleteName(),
'autoFill' => true,
],
'options' => ['class' => 'form-control']
]),
],
The id of the search field is plsearch-name
The js:
jQuery('#plsearch-name').autocomplete({"source":[{"value":"PE 150","label":"PE 150"}...],"autoFill":true});
If I'm setting the appendTo in clientOptions to '#plsearch-name', then it doesn't show up at all, however it is correct, isn't it? I don't see any styling in it.
What also quite interesting is:
<input
type="text"
id="plsearch-name"
class="form-control ui-autocomplete-input"
name="PlSearch[name]"
autocomplete="off"/>
What is this autocomplete="off" doing there?
Can you please point me to the right direction? Thanks a lot!
This Problem is fixed here: https://github.com/yiisoft/yii2-jui/commit/36468550d72bce9d963149abe85b13ea2f3a8c18
The JQuery UI Version should be updated to 1.12
"require": {
"yiisoft/yii2": "~2.0.4",
- "bower-asset/jquery-ui": "1.11.*#stable"
+ "bower-asset/jquery-ui": "~1.12.1"
},
i have form with two pjax. (one inside two) when clicked link in second PJAX send query to server but in field "X-PJAX-Container" write ID first container.
Pjax::begin([
'id' => 'register-form'
]);
...
Pjax::begin([
'id' => 'que'
]);
echo yii\helpers\Html::a('update', ['/portal/que/gr-usl/');
Pjax::end();
...
Pjax::end();
location after click update : /portal/que/gr-usl?_pjax=%23register-form
request header
X-PJAX:true
X-PJAX-Container:#register-form
X-Requested-With:XMLHttpRequest
if set data-pjax for link #que request header not changed.
for all link in inside pjax disabled data-pjax an href change to onclick with function
$.pjax({url: $(el).attr('link'), container: '#pjax-grusl'});
links has code
echo yii\helpers\Html::a('update', null,[
'data-pjax' => 'false',
'link' => \yii\helpers\Url::to(['/portal/que/gr-usl/',
'ids' => $ids,
'filter' => $filter,
'gr' => $gr
]),
'onclick' => 'selGr(this)'
]);
but its should work from box :( i don't understand why click by link don't find first pjax container from dom tree.
I am using the the Cake
<?= $this->Form->input('vehicles._ids', ['label' => 'Vehicle', 'options' => $vehicles, 'multiple' => 'checkbox', 'ng-model' => 'vehicles']); ?>
For each check box I want to add the custom attributes: 'ng-model'
I can see that the generation of multiple checkboxes is handled by the class file MultiCheckboxwidget.php and checkboxes use the 'checkbox' template:
'checkbox' => '<input type="checkbox" name="{{name}}" value="{{value}}"{{attrs}}>',
But since by default this uses {{attrs}} I can't see why my custom ng-model attribute isn't being added to the generatred form input. Instead this is the amrk-up crearted by the helper:
<input type="checkbox" name="vehicles[_ids][]" value="1"id="vehicles-ids-1" class="ng-valid">
How can I add ng-model to each of the checkbox inputs?
Upgrading my verison of CakePHP form 3.3.12 to 3.4 resolved the issue, the formhelper must have been refined in the latter versions.