This is how I do it:

$field->addMultiOption('', '(choose one)');

On Mon, May 4, 2009 at 4:33 PM, Philip G <[email protected]> wrote:

> What's the best way to add an initial empty value, while still retaining a
> select menu as required?
>
> This doesn't work very well. It, unfortunately, makes the first value '0'
> and then accepts it as a valid value:
> $valid_states = array ();
>       $valid_states[] = null;
>       while ( ($row = $stmnt->fetch( Zend_Db::FETCH_ASSOC )) ) {
>          $valid_states[$row['COUNTRY_SUBDIV_CD']] =
> $row['COUNTRY_SUBDIV_NM'];
>       }
>
>       $field = new Zend_Form_Element_Select( 'state', array (
>          'multiOptions' => $valid_states,
>          'required' => $this->consumer_required,
>          'label' => 'State',
>          'filters' => array ( 'StringTrim',
>             'StringToUpper' ) ) );
> ----------------------------
>
> I need to create an initial blank, non-value, within the select menu, so
> people are forced to make a selection, instead of just taking the default
> value.
> (not to mention one of the select menus is a mutigroup, and they don't like
> one of the multigroup options being selected by default).
>
>
> ---
> Philip
> [email protected]
> http://www.gpcentre.net/
>

Reply via email to