Yii Framework Forum: Multimodelform - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Multimodelform multimodelform dont work with scenearios? Rate Topic: -----

#1 User is offline   eliasfire2 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 18-June 12

Posted 18 March 2013 - 04:36 PM

Hi! my questions its simple: multimodelform dont work with scenearios?

i defined my scenario in my model, in RULES, like this:


array('nombre_seccion, id_sala_ciclo_anio, id_nivel, id_seccion, alu_mat_tot, alu_mat_var, id_turno, asistencia_medica, id_localizacion', 'required' , 'on'=>'adulto'),


then in my AdultoController, in actionCreate :

public function actionCreate() {
		Yii::import('ext.multimodelform.MultiModelForm');
		
		$id=Yii::app()->user->id;
		
		$establecimientousuario = UsuEstPla::model()->find('id_usuario = :id_uno',array(':id_uno'=>$id));
		$establecimiento = Establecimiento::model()->find('id_establecimiento = :id_uno',array(':id_uno'=>$establecimientousuario->id_establecimiento));
        $responsable = Responsable::model()->find('id_responsable = :id_est', array(':id_est'=>$establecimiento->id_responsable));
		
        $model = new Planilla;
		
		$detallePlanilla = new DetallePlanilla('adulto');
		
		$validatedDetalles = array();  
		
		

		if(isset($_POST['Planilla']))
		{
			
			
				
            //validate detail before saving the master
			$detailOK = MultiModelForm::validate($detallePlanilla,$validatedDetalles,$deleteItems);

			if ($detailOK && empty($validatedDetalles))
			{
				Yii::app()->user->setFlash('error','No detail submitted');
				$detailOK = false;
			}

			if(
			    $detailOK &&
				$model->save()
				)
			{
				//the value for the foreign key 'groupid'
				$masterValues = array ('id_planilla'=>$model->id_planilla);

				if (MultiModelForm::save($detallePlanilla,$validatedDetalles,$deleteItems,$masterValues))
					$this->redirect(array('admin','id'=>$model->id_planilla));
			}
		}
     
		$this->render('create',array(
			'model'=>$model,
			'detallePlanilla'=>$detallePlanilla,
			'validatedDetalles' => $validatedDetalles,
			'establecimiento' => $establecimiento,
		    'responsable'=>	$responsable
		));
	}


but when I try to save the data does not validate $detallePlanilla
I download the demo of multimodelform and I Modify the code to use the scenario and did not work

any suggestions?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users