[eluser]Michael Wales[/eluser]
Just an explanation here:
The form_dropdown() function wants a name, an array of options, the initially selected option, and then any javascript. You had that pretty much down - what's confusing you was the array of options.
Let's say we have the following array:
Code:
$array = array('l' => 'Large',
('xl' => 'Extra Large',
('xxl' => 'Extra Extra Large');
The dropdown form that is generated will look like this:
Code:
<select size="1">
<option value="l">Large</option>
<option value="xl">Extra Large</option>
<option value="xxl">Extra Extra Large</option>
</select>
To make one of these items the initial selection - we have to give CodeIgniter the value attribute of the option you want selected - so, if we pass 'xl' to the helper function, our dropdown now looks like:
Code:
<select size="1">
<option value="l">Large</option>
<option value="xl" selected>Extra Large</option>
<option value="xxl">Extra Extra Large</option>
</select>
Note the selected in xl now.
In your case - you wanted an instructional option, so we're just going to tack on another value within our array - at the beginning, so it's at the top when people click the dropdown.
Code:
$data['Names']['default'] = '--Select Client--';
The helper function will generate an option statement for this array variable that looks like:
Code:
<option value="default">--Select Client--</option>
And when you pass the value 'default' to the helper function, it of course - adds the selected attribute to this option tag.