cakephp form helper select box with selected value
17,488
I've tried your code and it works nice. "Private" appears selected by default.
Related videos on Youtube
Author by
geoffs3310
Professional web developer for a multi-national, multi-million dollar company. Proficient in PHP, OOPHP, cakePHP, XHTML, CSS, Javascript, jQuery, Drupal, Wordpress.
Updated on June 04, 2022Comments
-
geoffs3310 almost 2 years
I am using the cakephp form helper. Basically I want to output a select box with 2 options, public and private. I want private to be selected by default. Does anyone know how to get the private option selected by default? This is what I have so far:
echo $this->Form->input('profile', array( 'type' => 'select', 'options' => array('public' => 'public', 'private' => 'private'), 'selected' => 'private' ));
The private value isn't selected though
Thanks
-
mark about 13 yearsyou should not use "selected" - see dereuromark.de/2010/10/07/cakephp-beginner-tips for details
-