cakephp form helper select box with selected value

17,488

I've tried your code and it works nice. "Private" appears selected by default.

Share:
17,488

Related videos on Youtube

geoffs3310
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, 2022

Comments

  • geoffs3310
    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

Related