-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
The subcat is just loading after the right json response. #7
Comments
How are you creating your dependent dropdown widget markup (are you setting the |
Note: if you have upgraded to latest yii2 version, there is a major change in CSRF validation and AJAX/POST requests will fail with a 400 bad gateway error. You need to add This is a core framework change. Refer this commit and the related issue. |
Thank for your reply. 1: My dependent dropdown widget markup is OK, because the Ajax post for subcats can be triggered by the parent category click event. 2: I have upgraded to latest YII2 version. but i don't think the CSRF validation is the problem, as the screenshot for Json response which i attached shows, I got the response from the server. so it may be a Js problem, we got a right response with the right JSON format, but it shows loading. |
Cannot replicate this in any of my tests. Can you check or post your markup of the the DepDrop widgets? |
Below is my _form.php
thanks a lot. |
The echo Select2::widget([
'name' => 'firstCat',
'options' => ['id' => 'parentid', 'placeholder' => 'select'],
'data' => ArrayHelper::map(Category::find()->where('parent_category_id IS NULL')->asArray()->all(), 'id', 'category_name')
]); In addition, your markup for the child echo $form->field($model, 'category_id')->widget(DepDrop::classname(), [
'options' => ['id' => 'subcat-id', 'placeholder' => 'Select...'],
'type' => DepDrop::TYPE_SELECT2,
'select2Options'=>['pluginOptions'=>['allowClear'=>true]],
'pluginOptions' => [
'depends' => ['parentid'],
'url' => Url::to(['subcat'])
]
]); |
Thanks for your patience. But it is still not working. It must be the Js problem. May be i missed some Js file or imported unnecessary Js files. I will figure it out and then reply you here. Anyway thank you again. |
My controller:
The Json response:
I think my format is right, but it is not work like below:
The text was updated successfully, but these errors were encountered: