06-08-2010, 08:54 AM
[eluser]digitaldivaradio[/eluser]
I have two drop down menus that are a simple arrays, occupations and states. This is a new user reg form. Both drop downs are required when the user submits the form.
When the user submits and fails validation all my text fields are repopulating, but not the drop-downs. I would like to make it easier on the user. Can you help me find the right way to repopulate a drop down?
Here is my code.
VIEW
CONTROLLER
I have two drop down menus that are a simple arrays, occupations and states. This is a new user reg form. Both drop downs are required when the user submits the form.
When the user submits and fails validation all my text fields are repopulating, but not the drop-downs. I would like to make it easier on the user. Can you help me find the right way to repopulate a drop down?
Here is my code.
VIEW
Code:
$occupation = array(
'' => 'SELECT YOUR OCCUPATION:',
'1' => 'Architect / Designer',
'2' => 'Landscape Architect / Designer',
'3' => 'Commercial Contractor',
);
<?php
echo form_label('Occupation: <span class="requiredinfo">*</span>', 'occupation');
echo form_dropdown('occupation', $occupation, '');
?>
CONTROLLER
Code:
$this->form_validation->set_rules('occupation', 'Occupation', 'trim|required');
if ($this->form_validation->run() == FALSE)
{
$this->signup();
}