Hello All ,
Form Model:
<?php
class MyForm extends CFormModel
{
public $field1;
public $field2;
public function rules()
{
return array(
array('field1','required'),
);
}
}
?>
Controller
$model=new MyForm;
// if it is ajax validation request
if(isset($_POST['ajax']) && $_POST['ajax']==='my-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
// collect user input data
if(isset($_POST['MyForm']))
{
$model->attributes=$_POST['MyForm'];
// validate user input and redirect to the previous page if valid
if($model->validate() )
echo 'Correct <img src='http://www.yiiframework.com/forum/public/style_emoticons/default/smile.gif' class='bbc_emoticon' alt=':)' />';
}
// display the login form
$this->render('form',array('model'=>$model));
but when i try to submit form and put value in field2, data not display again (blank).
but this is done when i made model be:
public function rules()
{
return array(
array('field1,field2','required'),
);
}
let me know solution for this problem.
thank you