I have code using QuickForm that creates a select widget with the following:
$form->addElement( 'select', 'state_id', 'State:', statesArray() );
statesArray()
queries the database to get the states available and returns an associative array with the ids linked to the state names. I'm using a similar technique throughout the solution.
What I'd like to do is prepend this array with two options that are disabled, so that by default the select menu says something like "Please select a state" followed by a dash, both of which are disabled. If I weren't using QuickForm, the select would have the following as the first two options:
<option value="" disabled="disabled">Select a State</option>
<option value="" disabled="disabled">-</option>
Both options are disabled, and if the user leaves the option on the first value, the select widget submits an empty value which is made invalid by the form checking code.
Is there a way to do this with QuickForm?
Thanks, Chuck