I believe it's 'empty => 'Select your State'. If the param is false,
null, or the empty string, Cake outputs an empty option.

On Sun, Oct 4, 2009 at 8:13 AM, Dave Maharaj :: WidePixels.com
<d...@widepixels.com> wrote:
>
> I had a same / similar question for input selects which is related to this.
>
> I have my echo $form->input('State'); which is populated by a find list...so
> I have all my States. How can I add so first option to be "Select your
> State" with no value? Right now Alabama shows up first and if a user does
> not select a State Alabama is automatically saved.
>
> $selected = array('option' => 'Select your State', 'value' => '0')?
>
> Thanks,
>
> Dave
> -----Original Message-----
> From: Miles J [mailto:mileswjohn...@gmail.com]
> Sent: October-04-09 7:35 AM
> To: CakePHP
> Subject: Re: showEmpty?
>
>
> You should only be using input().
>
> echo $form->input('State', array('options' => array('NJ' => New Jersey',
> 'NY' => 'New York'), 'empty' => false));
>
> On Oct 3, 7:33 pm, Gonzalo Servat <gser...@gmail.com> wrote:
>> On Sun, Oct 4, 2009 at 7:21 AM,
> gimperdan...@gmail.com<gimperdan...@gmail.com> wrote:
>>
>> [..snip..]
>>
>> > This is what I have:
>>
>> > echo $form->select('State', array('NJ' => New Jersey', 'NY' => 'New
>> > York'));
>>
>> > I want to remove the empty option of this select box. According to
>> > the API I need to add $showEmpty = false to the code above.. but
>> > where do I add it? I tried in several different locations and it won't
> work.
>>
>> The function's arguments are:
>>
>> select($fieldName, $options = array(), $selected = null, $attributes =
>> array(), $showEmpty = '')
>>
>> You only supplied the first and second arguments so if you want to
>> keep the defaults for the rest except for $showEmpty, you'd need to do
>> something like the following:
>>
>> echo $form->select('State', array('NJ' => 'New Jersey', 'NY' => 'New
>> York'), null, array(), false)
>>
>> (notice I kept the defaults "null" and "array()" for the arguments
>> between $options and $showEmpty)
>>
>> - Gonzalo
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to