I learn a CForm class from this guide. I encounter a problem. I can’t catch submited data via $form->submitted().
My controller:
public function actionadd()
{ /* It is my page with html-form */
$this->render('form_add');
}
public function actionadd2()
{ /* It is page which validates data */
Yii::import('application.models.TravellerForm');
$model = new TravellerForm;
$form = new CForm(array(), $model);
if($form->submitted())
{
/* HERE IS THE PROBLEM. IT IS ALWAYS RETURNS FALSE. BUT I HAVE <input type="submit" name="submit" value="Submit"> IN MY HTML-FORM */
//I can't execute code here
}
$this->redirect(array('traveller/add'));
}
public function actionadd3()
{
//Well done
}
My view with html-form (this code produce correct button <input type="submit" name="submit">, but it is not catched in actionadd2):
<?php echo CHtml::form( array('add2') ); ?>
<input type="text" name="name" value="" /> <br />
<?php echo CHtml::submitButton('Submit', array('name'=>'submit', 'id'=>'submit') ); ?>
<?php echo CHtml::endForm(); ?>
My TravellerForm class (It is simple and it is just for my tests):
class TravellerForm extends CFormModel
{
}
Where is the problem?