title: Yii multiple update of child records based on current parent record
body: <p>I am trying to come up with a way of updating multiple records of a model and as I am using YiiBooster I have seen that you can do bulk actions using the Extended Grid.</p>
  
  <p>Most of the examples that I have found on the web are showing how to delete multiple records using Ajax but my requirements are slightly different. As a newbie to Yii I am struggling to work out a suitable solution to this.</p>
  
  <p>Basically I have 2 models, a parent and a child with a one-to-many relation. In the child model I have a field which references which parent it belongs to using the parent ID.</p>
  
  <p>In the front end of the application the user is supposed to navigate to the parent update view and then see a list of all children assigned to that parent. I have created a modal window that shows a grid list of all children with the ability to perform a bulk update action. This will then assign the parent ID to all of the children that were selected.</p>
  
  <p>Can anyone help me out with this as I am unsure what I need to edit in the extended grid view and controller that will be used to update the records?</p>
  
  <p>In my parent update view I pull in the index view of the children using renderPartial, as follows:</p>
  
  <pre><code>&lt;?php $this-&gt;renderPartial('application.modules.children.views.childviews.addChild', array('dataProvider' =&gt; new CActiveDataProvider('Children'))); ?&gt;
  </code></pre>
  
  <p>I then have an Extended grid in my child index view:</p>
  
  <pre><code>&lt;?php
  $this-&gt;widget('bootstrap.widgets.TbExtendedGridView', array(
      'type' =&gt; 'striped bordered',
      'id' =&gt; 'children-grid',
      'dataProvider' =&gt; $dataProvider,
      'bulkActions' =&gt; array(
          'actionButtons' =&gt; array(
              array(
                  'buttonType' =&gt; 'link',
                  'type' =&gt; 'primary',
                  'size' =&gt; 'small',
                  'label' =&gt; 'Bulk Action',
                  'url' =&gt; array('batchUpdate'),
                  'htmlOptions' =&gt; array(
                      'class' =&gt; 'bulk-action'
                  ),
                  'id' =&gt; 'child_id',
                  'click' =&gt; ''
              )
          ),
          'checkBoxColumnConfig' =&gt; array(
              'name' =&gt; 'child_id'
          ),
      ),
      'columns' =&gt; array(
          'child_id',
          'child_status',
          'parent_id',
          array(
              'class' =&gt; 'bootstrap.widgets.TbButtonColumn',
              'buttons' =&gt; array(
                  'update' =&gt; array(
                      'label' =&gt; '&lt;i class="icon-user"&gt;&lt;/i&gt; &lt;span&gt;View Child&lt;/span&gt;',
                      'options' =&gt; array('class' =&gt; 'btn btn-small'),
                      'url' =&gt; 'Yii::app()-&gt;createUrl("children/update", array("id"=&gt;$data-&gt;child_id))',
                  ),
              ),
          ),
      ),
  ));
  ?&gt;
  </code></pre>
  
  <p>I am guessing that I need some kind of onclick event that calls an update action in the controller and this action updates the parent_id column of all selected records to the parent id of the current parent update page?</p>
  
  <p>I hope someone can help and many thanks in advance. </p>