Skip to content
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

yii2-widgets depDrop on update scenario #95

Closed
dubeymahi48 opened this issue Jun 23, 2014 · 4 comments
Closed

yii2-widgets depDrop on update scenario #95

dubeymahi48 opened this issue Jun 23, 2014 · 4 comments
Labels

Comments

@dubeymahi48
Copy link

please help me for depDrop on update scenario::--

When we call an updateAction() then second dropdown is blocked until we not select previous dropdown. But if first dropdown is selected then second should be load the previous selected value.

field($model, 'country_pk')->dropDownList($model->countryList, ['prompt' => '-Choose a Country-', 'id' => 'country_pk']) ?>
<?php
echo $form->field($model, 'state_pk')->widget(DepDrop::classname(), [
    'options' => ['id' => 'state_pk'],
    'pluginOptions' => [
        'depends' => ['country_pk'],
        'placeholder' => 'Select State...',
        'url' => Url::to(['subcat'])
    ]
]);
?> 

onCreate() everything is OK..please help me how to enable the desable second dropdown if it have value why it bocked..

Thank you...

@kartik-v
Copy link
Owner

The dependent dropdown will be disabled only if it does not have a list of values (basically empty data source). Check the demo examples - there are dependent dropdowns with pre populated data and enabled for update.

You have two options:

  • Ensure the dependent dropdown data is pre-populated with list of dependent values when you are showing the input for update at document load (write code for update scenario to generate the dependent data array).
  • If you do not want to generate the data yourself... you can set the initialize property to true in pluginOptions, this will run the ajax request on document load to populate the dependent dropdown.

@dubeymahi48
Copy link
Author

Thanx i have done this please close this issue..
Problem solved...
Thanx again..

@akshaybande81
Copy link

Can you share the code for update .

@paskuale75
Copy link

@akshaybande81 you could pass the param 'selected' in the url with your model->attribute value

'url' => Url::to(['subcat','selected' => $model->myAttribute])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants