Question

$x=array('a','b','c');
echo form::dropdown('test', $x, 'b');

I'm using the Kohana form helper to build forms, but I've hit a snag. The above test code doesn't display the default value as it should, as written in the docs. Ideas?

Was it helpful?

Solution 2

It uses the key of the array, not the value, to determine what default value to show.

OTHER TIPS

Your array should be set up like this:

$x = array('a'=>'a', 'b'=>'b', 'c'=>'c');

By setting the array the way you are doing it your keys are all numeric. If you want the keys to be numeric you would need to have a number for your default value:

echo form::dropdown('test', $x, 2)

Either one of these changes would be ok depending on how you want your application set up.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top