Demogorgorn yii2 ajaxSubmitButton action url problem

The ajaxSubmitButton on an activeForm works well, unless i render it via ajax. If i do this it does not use the action given with the button.

In brief, I have an edit button next to a gridview record. It has an onclick() that will run JS that will, via an action called ‘getRecord’, use the record’s PK to get and display the form and record’s data in a bootstrap modal so that the user can view/edit it. All this works fine, but if i then make and submit these edits, the ajaxsubmitbutton will call the previous ‘getRecord’ action instead of the ‘editHiveRecord’ action given as the button’s url.

the button is:

<?php AjaxSubmitButton::begin([

'label' =&gt; 'Submit Edits',

'ajaxOptions' =&gt; [


  [b] 'url'=&gt;'editHiveRecord',[/b]


'options' =&gt; ['class' =&gt; 'btn btn-success', 'type' =&gt; 'submit', 'id'=&gt;'editHiveSubmit'],




Note: I can enter garbage for the ‘ajaxOptions’ and it will not throw an error- as if it is ignoring them.

Has anyone else experienced this problem when rendering a form with the ajaxsubmitbutton via ajax?



One solution is try to use different id for each ajax refresh. I mean …give dynamic id to ajaxbutton.

Second solution is rebind event. I hope first solution will work.


Chandran Nepolean

Thanks for the suggestion, but it looks like i found the problem. I returned the form with the loaded model from the controller with renderPartial- it works if i use renderAjax.

thanks again