Jørgen
Jørgen

Reputation: 3567

Yii2.0 - Ajax form submit and dropdown update

I have a model with a category relation. In my model form i have dropdown to choose from existing categories, and a modal popup for adding additional categories. But the modal submit reloads the page to insert and update.

Now, id like the modal submit button to close the modal, submit the form trough ajax and update the dropdown field.

I remember doing this in Yii 1.1, is there a neat way to do this in Yii2.0? Any pointers?

Upvotes: 0

Views: 1961

Answers (1)

Tahir
Tahir

Reputation: 733

You can manually submit the form with ajax also. All you need to do is listen to beforeSubmit event in javascript.

An example of such implementation is available in this issue.

Also you can find some docs about this and other yii ActiveForm javascript events here.

Hope it helps.

Upvotes: 3

Related Questions