New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[initialize = true] do not work sometimes #16
Comments
This is resolved with latest release of |
Huge thnx, but now it is always empty value :( I noticed in my case work this line: return false since I use Select2. |
You need to check the documentation and demos closely again on HOW you need to set your nested dependency. Check the demo page for usage with Select2. Also note that if you need to set a value via ajax ... you need to return the |
I "smoking" the docs second day :) May be you can find a minute to review my code plz? if (Yii::$app->user->identity->isAdmin) {
$userData = ArrayHelper::map(User::find()->asArray()->all(), 'id', 'username');
echo $form->field($model, 'user_id')->widget(Select2::className(), [
'data' => $userData,
'hideSearch' => true,
'pluginOptions' => [
'placeholder' => $userPlaceholder,
'allowClear' => true,
],
])->label(Yii::t('app', 'User'));
} else {
echo Html::activeHiddenInput($model, 'user_id');
}
echo $form->field($model, 'site_id')->widget(DepDrop::className(), [
'type' => DepDrop::TYPE_SELECT2,
'data' => [$model->site_id => 'xxx'],
'pluginOptions' => [
'placeholder' => $sitePlaceholder,
'url' => Url::toRoute('client-site/select-list'),
'depends' => ['variable-user_id'],
// 'initDepends' => ['variable-user_id'],
// 'initialize' => true,
],
'select2Options' => [
'hideSearch' => true,
'pluginOptions' => [
'allowClear' => true,
],
],
])->label(Yii::t('app', 'Site'));
echo $form->field($model, 'page_id')->widget(DepDrop::className(), [
'type' => DepDrop::TYPE_SELECT2,
'data' => [$model->page_id => 'xxx'],
'pluginOptions' => [
'placeholder' => $pagePlaceholder,
'url' => Url::toRoute('client-page/select-list'),
'depends' => ['variable-user_id', 'variable-site_id'],
'initDepends' => ['variable-user_id', 'variable-site_id'],
'initialize' => true,
],
'select2Options' => [
'hideSearch' => true,
'pluginOptions' => [
'allowClear' => true,
],
],
])->label(Yii::t('app', 'Page')); The actions do not returns 'selected' at all, just 'output'... After some modest research, I found if I change this line in self.setDep($id, depends, len, false); to self.setDep($id, depends, len, $el.val()); it work but excepting last child... Also, some value issues in var elVal = $el.val(); at the first line of if (selected === null) {
selected = elVal;
} at second to thnx |
In the last child dropdown change your widget plugin configuration to the following: [
'initDepends' => ['variable-user_id'], // this should be the topmost parent
'depends' => ['variable-site_id'], // this should be the immediate parent
'initialize' => true
] Also ensure you got the latest code for kartik-v/yii2-widget-select2, kartik-v/yii2-widget-depdrop, and kartik-v/dependent-dropdown |
Huge thnx! It make understaning self.setDep($id, depends, len, false); to: self.setDep($id, depends, len, $el.val()); Could you explain what the false means here? The parameter seems to be for the value, but there is only one call with 'false' :o thnx! |
Also, I just noticed, Select2 clear action do not fire the refreshing of deps. Just yerstarday it was ok. |
As mentioned before - Ensure you got the latest code updated for kartik-v/yii2-widget-select2, kartik-v/yii2-widget-depdrop, and kartik-v/dependent-dropdown There are updates to all the above extensions. I fixed the above as well for |
composer.json part: ...
"kartik-v/yii2-widget-select2": "dev-master",
"kartik-v/dependent-dropdown": "dev-master",
"kartik-v/yii2-widget-depdrop": "dev-master",
... is it ok? Anyway, for now all ok... almost :) The 'clear' of DepDrop widgets work ok, but 'clear' of Select2 ( Also, I noticed(after today updates), there is 'open/close' of child selector's when 'clear' clicked. thnx |
With regards Select2 --- refer this issue There is an issue in the Select2 plugin which is been reported to the Select2 Plugin team I have provided a temporary workaround fix (hack) in the yii2-widget-select2 to overcome the above issue. It ideally should get resolved completely once the fix is provided in the plugin. |
Ok this is resolved now - update all packages via composer. |
Huge thanks! but It seems the very last update add new 'clear' related issue. Now it fire ajax, but with previous(not 0|null) id. |
This is resolved. |
Seems to be all ok for now :) |
It work ok most times, but 1-2 times for ~10 tries I have empty value for last selector :( The list is loaded ok and able to select, but value of the field is lost :(
The text was updated successfully, but these errors were encountered: