multimodelform submit

Hi guys,

Kindly someone help me solve a problem with multimodelform extension. It’s doing validation well but when all errors clear, the form doesn’t do anything when I click submit.

I have two tables namely requisitions and requisitionitems

Requisition table fields

requisitionid (PK) auto_increment

ministryid

departmentid

requisitionitems table fields

id(PK) auto_increment

requisitionid(FK)

itemnumber*

itemid*

unitofmeasure*

quantity*

My controller code




	public function actionNewrequisition()

	{

            Yii::import('ext.multimodelform.MultiModelForm');

            

		$model=new Requisitions;

                

                $reqitems=new Requisitionitems;

                

                $validatedMembers = array();  //ensure an empty array

                


		if(isset($_POST['Requisitions']))

		{

			$model->attributes=$_POST['Requisitions'];

                        

			if(MultiModelForm::validate($reqitems,$validatedMembers,$deleteItems) && $model->save())

                        {

                            $masterValues = array('requisitionid'=>$model->requisitionid);

                            

                            if(MultiModelForm::save($reqitems,$validatedMembers,$deleteMembers,$masterValues))

                            {

                                $this->redirect(array('view','id'=>$model->requisitionid));

                            }

                        }

                                                                                  

                                               

		}


		$this->render('newrequisition',array(

			'model'=>$model,

                        'reqitems'=>$reqitems,

                        'validatedMembers'=>$validatedMembers,

		));

	}



My View Code




<div class="form">


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

	'id'=>'requisitions-form',

	// Please note: When you enable ajax validation, make sure the corresponding

	// controller action is handling ajax validation correctly.

	// There is a call to performAjaxValidation() commented in generated controller code.

	// See class documentation of CActiveForm for details on this.

        'enableClientValidation'=>true,

        'clientOptions'=>array('validateOnSubmit'=>true),    

	'enableAjaxValidation'=>false,   

)); 


          


?>

    

  


	<p class="note">Fields with <span class="required">*</span> are required.</p> 


	<?php echo $form->errorSummary($model); ?>


        //I left out the master table code....          

                   

    

                    <?php

                    

                    $requisitionitemsFormConfig = array(

                        'elements' => array(

                            'itemnumber'=>array(

                                'type'=>'text',

                            ),

                            'stockrefno'=>array(

                                'type'=>'text'

                            ),

                            'itemid'=>array(

                                'type'=>'text'

                            ),

                            'unitofmeasure'=>array(

                                'type'=>'text'

                            ),

                            'quantity'=>array(

                                'type'=>'text'

                            ),

                            'estimatedunitprice'=>array(

                                'type'=>'text'

                            ),

                            'estimatedtotalprice'=>array(

                                'type'=>'text'

                            )

                        )

                    );

                    

                    $this->widget('ext.multimodelform.MultiModelForm',array(

                            'id' => 'id_member', //the unique widget id

                            'formConfig' => $requisitionitemsFormConfig, //the form configuration array

                            'model' => $reqitems, //instance of the form model

                            'tableView' => true,

                            //if submitted not empty from the controller,

                            //the form will be rendered with validation errors

                            'validatedItems' => $validatedMembers,


                            //array of member instances loaded from db

                            //'data' => $reqitems->findAll('requisitionid=:requisitionid', array(':requisitionid'=>$model->requisitionid)),

                        ));                    

                    

                    ?>

                        

                   


    <div class="row buttons"></div>

		<?php echo CHtml::submitButton('Submit',array('class'=>'btn btn-primary')); ?>

    </div>


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


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



Find the attached screen shot of my view

Hi,

I solved the above problem. It was as a result of a required field in the dependent table.

My other problem is the table view.

Table view doesn’t show the first row until I click on ‘Add Item’.

[list=1]

[*]Is it possible to get the first row show automatically?It’s currently showing just labels in table heading

[*]Is it possible to make the first row mandatory to ensure at least one dependent item is saved?

[*]How can I show clone ids in the first column of each new row?

[/list]

thanks for your help.