form goes back to default

Hi,

why is it that when,

  1. I select an option from my dropdown menu

  2. input some strings at the input forms

  3. tick some checkboxes

  4. submit the form

when the data comes out, all of those 1,2,3 goes back to default mode

even though the pulled data is correct…Like, the dropdown doesn’t stick with what i selected, the checkboxes that i ticked doesn’t remain checked, the strings that I input doesn’t remain at the form

here’s my code




echo CHtml::beginForm(array('advancecvsearch','r'=>'wsrecruitcvhead/advancecvsearch'),$method='get');

echo "Date Posted: ".Chtml::activeDropDownList($model, 'DateCreated', $model->getTimeOptions())."<br />";

echo "Available to Work Sunday: ".CHtml::checkBox('sun', false)."<br />";

echo "Available to Work Monday: ".CHtml::checkBox('mon', false)."<br />";

echo "Available to Work Tuesday: ".CHtml::checkBox('tue', false)."<br />";

echo "Available to Work Wednesday: ".CHtml::checkBox('wed', false)."<br />";

echo "Available to Work Thursday: ". CHtml::checkBox('thurs', false)."<br />";

echo "Available to Work Friday: ". CHtml::checkBox('fri', false)."<br />";

echo "Available to work Saturday: ". CHtml::checkBox('sat', false). "<br />";

echo "Resume Title ".CHtml::textField('resumetitle','',array('id'=>'resumetitle'))."<br />";

echo "Resume Summary Introduction ".CHtml::textField('resumesummaryintroduction','',array('id'=>'resumetitle'))."<br />";

echo "Summary of Position Sought ".CHtml::textField('summaryofpositionsought','',array('id'=>'summaryofpositionsought'))."<br />";

echo "Summary of Skills ".CHtml::textField('summaryofskills','',array('id'=>'summaryofskills'))."<br />";

echo CHtml::submitButton('submit', array('value'=>'Search','name'=>'Search'));

echo CHtml::endForm();



You have to collect the data in the controller, pass to the view and in the view use CHtml::activeTextfield.

I advice you to generate a crud with Gii and inspect attentively the code of create/update and the code of the views create, update and _form.

I’ve solved the dropdown list by adding adding the options array




Chtml::activeDropDownList($model, 'DateCreated', $model->getTimeOptions(),array('options'=>array($_GET['Wsrecruitcvhead']['DateCreated']=>array('selected'=>true)))).



and also the input forms, by adding the $_GET[‘param’] at the value




CHtml::textField('resumetitle',$_GET['resumetitle'],array('id'=>'resumetitle'))



one last problem is the checkbox(es)

when I tick, none remains ticked

You are going on a rong way, take a look at how is suggested to do, instead of implement your own variant.

You are loosing lot of time reinventing worst what is already done.

Generate a crud with Gii and inspect attentively the code of create/update and the code of the views create, update and _form.

Sassori you have to use activeCheckBoxList or activeCheckBox , your model dosent see a rules for your checkboxes.

It have to be defined in a model, and you have to set a rule for checkbox