I am creating a form like this:
$model = new RequestForm;
$form = new CForm('application.views.site.requestForm', $model);
I am saving the form data into a session, so that if the user visits some other pages where there are similar forms, the inputs are already filled. requestForm.php looks something like this:
return array(
'showErrorSummary' => false,
'elements' => array(
'first_name' => array(
'type' => 'text',
'class' => 'standard-input',
'value' => Yii::app()->requestFormValues->first_name,
),
)
Now the problem occurs when I submit the form. Say I have modified the first name – it gets the data from the session instead of the POST data from the input. How can I verify, in requestForm.php or in the requestFormValues component if the form was submitted so I do not specify a default value ?
Kind Regards,
Marian
Use default value only when POST is set. Otherwise, use default
is this helps you?