US-1234
US-1234

Reputation: 1529

Submitting two forms in one button - Yii FrameWork

I am trying to submit more than two forms in one button by using JS, how could i proceed to do this for yii active forms.

Upvotes: 1

Views: 700

Answers (2)

chameera
chameera

Reputation: 389

This is not specific to Yii. You can handle this using javacript. Write a function for on click event of the submit button. serialize the form1, serialize the form2. Concatenate two serialize results and pass it to an ajax request.

$('your_submit_button_selector').on('click', function(event){
   event.preventDefault(); 
   formData = $('your_form1_selector').serialize()+$('your_form2_selector').serialize();
   $.ajax({
       url: submitUrl,
       data: formData,
       type: 'POST',
       success: function(data) {
        ...
       }
  }); 
 });

Upvotes: 3

Imtiaz Zaman Nishith
Imtiaz Zaman Nishith

Reputation: 490

Why don't you use this way...

jQuery('#yourForm1').submit();
jQuery('#yourForm2').submit();

Good Luck.

Upvotes: -1

Related Questions