Yii Forms

Hi Everyone

Im a real newbie in YII and to MVC. Im creating a basic form with 3 inputs, submit them and verify if the form is submitted at phase I . Im having ATM an error in the model, need a little support here. The ajax between marcas and models is working perfect btw.

Im getting the following error :

PHP Error

Undefined variable: model



<?php $this->pageTitle=Yii::app()->name; ?>

<?php echo Yii::app()->user->getFlash('busqueda'); ?>

Busqueda de Repuestos : 

<div class="form">

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






)); ?>

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

<div class="flash-success">


<div class="row">

		<?php  $models = marca::model()->findAll();?>

		<?php  $list = CHtml::listdata($models,'id','marca'); ?>

		<?php   echo CHtml::dropDownList('marca', $models,



'ajax' => array(

'type'=>'POST', //request type

'url'=>CController::createUrl('cargaModelo'), //url to call.

//Style: CController::createUrl('currentController/methodToCall')

'update'=>'#modelo', //selector to update

//'data'=>'js:javascript statement'

//leave out the data key to pass all form values through




<?php echo CHtml::dropDownList('modelo','', array('empty' => 'Modelos por marca')); ?>


<?php echo CHtml::TextField('repuesto') ?>


<div class="row buttons">

    <?php echo CHtml::submitButton('Busqueda'); ?>


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


public function actionIndex()


		// renders the view file 'protected/views/site/index.php'

		// using the default layout 'protected/views/layouts/main.php'

             $model=new IndexForm;



                    Yii::app()->user->setFlash('busqueda','Form Submitted');

                } else {

                    Yii::app()->user->setFlash('busqueda','Not submitted');







class IndexForm extends CFormModel


    public $marca;

    public $modelo;

    public $repuesto;

    public function rules()


        return array(

            array('marca, modelo', 'required'),





Thanks in advance for any help.

Hi alejandrowa,

public function actionIndex()



-           $this->render('index');

+           $this->render('index', array('model'=>$model));



And welcome to the forum. :)

Thank man, now is working and handling the communication back in forth between View and Controller. Im able to return now the variables submitted back to the View. Now Im going to create a query to the database with those variables.

Thanks again