$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?
$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?
It uses the key of the array, not the value, to determine what default value to show.
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.