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 editing or 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.

Thanks in advance.

You mean in your view you have grid generated from model?

‘In my model form i have dropdown to choose from existing categories’

for above you can just use pjax, as a widget or in your gridView

Here you have nice example:

http://www.yiiframework.com/wiki/772/pjax-on-activeform-and-gridview-yii2/

‘modal popup for editing or adding additional categories’

Now here you have to stop your submit action with (for example jQuery), or use button.

Then use write Ajax call to push your data to controller and close modal popup and $.pjax.reload(’#pjax-container’) to refresh your main grid, on ajax.success event.