Ajaxsubmit And Tabs

Ok I have working code using ajax submit to capture and insert records in my db. Currently though I have to go from one models view to another to have this execute. I am trying to combine all the code and execute from a view in the first model though.

Below is my code attempting that. It is displayed as the logic flows.

In this code below I am using a tab and render partial in ModelA and then eventually call the ajaxSubmitButton from ModelB and use ModelB controller to input data into my db.

The problem that I am running into now is it always inserts a record, but instead of inputting the right record it will insert the first record that is displayed in the render partial (ItemId = 1 regardless of which Item I execute the code from).


//Model A View 

$tabs = array(

array('id' => 'tab1', 'label' => 'tab', 'content' => $this->renderPartial('/modelB/_modelBView', array('model' => $model), true)),


$this->widget('bootstrap.widgets.TbTabs', array(

'type' => 'tabs',

'tabs' => $tabs,



if (!Yii::app()->user->isGuest)

$this->widget('zii.widgets.CListView', array(



    'template' => '{items}}',



echo $data->checkItem;


public function getCheckItem ()


    if (something...)


            echo 'Status Good'; 


    else {

        echo CHtml::ajaxSubmitButton(

                'Get Item',          




                    'data' => array('ItemId' => $this->ItemId, 'Type' => $this->Type),

                    'success' => "function(){window.location='".Yii::app()->createUrl('/modelC/list') . "'}",





//ModelB Controller

public function actionGetItem() 


    $connection = yii::app()->db;




        $connection = yii::app()->db;

        $sql = "INSERT INTO modelC (ItemId, Type)

                        VALUES(:item, :type)";


        $command->bindValue(":item", $_POST['ItemId']);

        $command->bindValue(":type", $_POST['Type']);




    catch(Exception $e)