http://book.cakephp.org/view/201/options-empty
On Fri, Apr 11, 2008 at 11:52 AM, RichardAtHome <[EMAIL PROTECTED]> wrote:
>
> Hi All :-)
>
> Cake 1.2.0.6311 beta
>
> I am using the following code to create a drop down select box for a
> field in a view:
>
> echo $form->input('institution_id',array("label"=>"Institution *",
> "class"=>"input", "div"=>"input mandatory", "selected"=>$preSelect-
> >select("institution_id")));
>
> ($preSelect is a custom helper that pre-selects an item from the list
> if it is present in the URL)
>
> As it stands, this code creates a drop down list as expected, but
> doesn't include an empty option.
>
> How do I get it to show an empty option at the top of the list (or
> better yet a 'Please Select...' option)?
>
> I've dug through the form helper code and I though this would work:
>
> echo $form->input('institution_id',array("label"=>"Institution *",
> "class"=>"input", "div"=>"input mandatory", "selected"=>$preSelect-
> >select("institution_id")),null,null,"Please Select....");
>
> and
>
> echo $form->input('institution_id',array("label"=>"Institution *",
> "class"=>"input", "div"=>"input mandatory", "selected"=>$preSelect-
> >select("institution_id"), "showEmpty"=>"Please Select..."));
>
> but try as I might, I can't get $form->input() to pass the "Please
> Select" message through to $form->select()
>
> Oddly enough, the $input->select() code should default to providing an
> empty select code ($showEmpty = '') if non is specified, so $form-
> >input() must be passing in false to stop this from happening.
>
> Any ideas what I'm doing wrong?
>
> Thanks in advance :-)
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---