Passing Form Data And Cgridview Data Simultaneously

I have a view having a single CHTML text field and a TbExtendedGridView. Selected rows from the tbExtendedGridView along with the text field data are to be submitted to the database. It is a batch addition process where each row along with the textfield data is one record.

I can get the selected rows using the js function js:{chk:$.fn.yiiGridView.getSelection(‘gridname’)}. How can I pass the textfield data along with the selected row data in the CHTML submit button.

View File:

<div class="form">

<?php $form=$this->beginWidget(‘CActiveForm’, array(



)); ?>

&lt;p class=&quot;note&quot;&gt;Fields with &lt;span class=&quot;required&quot;&gt;*&lt;/span&gt; are required.&lt;/p&gt;

&lt;?php echo &#036;form-&gt;errorSummary(&#036;model); ?&gt;


&lt;div class=&quot;row&quot;&gt;

    &lt;?php echo &#036;form-&gt;labelEx(&#036;model,'formname'); ?&gt;

    &lt;?php echo &#036;form-&gt;textField(&#036;model,'formname'); ?&gt;

    &lt;?php echo &#036;form-&gt;error(&#036;model,'formname'); ?&gt;


&lt;div class=&quot;row&quot;&gt;


    &#036;this-&gt;widget('bootstrap.widgets.TbExtendedGridView', array(           

        'type'=&gt;'striped bordered condensed',          


        'fixedHeader' =&gt; true,

        'headerOffset' =&gt; 40,             


        'dataProvider' =&gt; new CActiveDataProvider('Subfields',array(


                'order'=&gt;'tagno, slno',),                      

                'pagination'=&gt;array('PageSize'=&gt;20,), )),         

        'enablePagination' =&gt; TRUE,            



                'pager' =&gt; array(

                'cssFile' =&gt; false,

                'header' =&gt; false,

                'firstPageLabel' =&gt; 'First',

                'prevPageLabel' =&gt; 'Previous',

                'nextPageLabel' =&gt; 'Next',

                'lastPageLabel' =&gt; 'Last',),       



        'columns' =&gt; array(












&lt;div class=&quot;row buttons&quot;&gt;

    &lt;?php echo CHtml::submitButton('orgSubmit',  array(&quot;data&quot; =&gt; &quot;js:{chk:&#036;.fn.yiiGridView.getSelection('grsubfielddata')}&quot;)); ?&gt;




<?php $this->endWidget();?>

</div><!-- form -->

There is very nice article on Batch Processing, here is the link might help you

Thanks for the response

There were a few problems which I could solve

  1. How to convert the selected rows from the gridview to string

Solution: wrote a Javascript and converted the selected rows to string and assigned it back to a hidden field.

  1. Single assignment was not possible as there was a syntax error

as i was using only

$frm=>$_POST[fieldname] instead of


Not yet solved:

I could now pass all the records from the view to the Controller (which I can print using echo) but only the last record is getting added to the database.