1

I am stumped beyond belief.

I have a select box being generated by the cakephp form helper. I am feeding it an array of options, and passing an empty value... pretty standard stuff.

However, my "empty" field is showing up at the very bottom of the list.. not the top. So when the field loads, it just defaults to the first option... which is not the "empty" option.

Not a whole lot of room for error on the code here..

echo $this->Form->input('whatever',array('empty'=>'Choose One','options'=>$categories));

The only small item that might be important, is that $categories is a multi-array, so the select box has optgroups & options.

Is there some quirk/bug out there that I do not know of that is trying to force me to sneak into my scotch supply a few hours ahead of schedule?

edit: using the latest release of cakephp 1.3.x

1
  • Try setting 'type'=>'select' ? Commented Mar 4, 2012 at 18:38

1 Answer 1

1

I think that I once had the same problem. It turned out to be the data (options array).

Is there an option with an empty key? probably the last one then. this lead to the scenario I remember and seems to be the exact same thing. the form helper will override this empty key value pair then and not create a second one.

without more infos from your end this will be difficult to solve.

Sign up to request clarification or add additional context in comments.

3 Comments

You were 100% right you magnificent bastard :) And I was really looking forward to dipping into the scotch... guess I got to get back to the grind now.
I am sry to disappoint you an that one. and thx for the flours. not that big of a deal though. if sth like that happens and you spend some good time searching for the solution you don't forget it that easy :)
I just had the exact same situation -- there was an empty key in the options so that the default ended up not empty. This really saved me some time! Thanks!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.