QuickForm select element with disabled items
Posted: Sun Jan 24, 2010 11:14 pm
I have code using QuickForm that creates a select widget with the following:
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:
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
Code: Select all
$form->addElement( 'select', 'state_id', 'State:', statesArray() );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:
Code: Select all
<option value="" disabled="disabled">Select a State</option>
<option value="" disabled="disabled">-</option>Is there a way to do this with QuickForm?
Thanks,
Chuck