Saturday, May 1, 2010

Re: Selected option in select

OMG it's unbelievable. It works and I dind't do anything to it. If I hit F5, the selection disappears but if I click on the edit link, everything is OK. Good enough for me. Maybe it's the browser.

So, here are my to working solutions:

        $options=array(
            'Generatia 1'=>'Generatia 1',
            'Generatia 2'=>'Generatia 2',
            'Generatia 3'=>'Generatia 3',
            'Mesteri' => 'Mesteri'
        );
       
        //Using select, no lable
        echo $form->select('group', $options, array('selected' => $this->data['Profile']['group']));
       
        //Using input, with label
        echo $form->input('group', array(
                                        'options' => $options,
                                        'selected' => $this->data['Profile']['group'],
                                        'label' => 'Grup')
                          );


Thanks


On Sat, May 1, 2010 at 10:05 AM, WebbedIT <paul@webbedit.co.uk> wrote:
Why are we not using (and I have tested this using 1.2.6)?

$form->input('Profile.group', array('options'=>$groups));

Where $groups is the options array relating to the Profile.group
field, the fact you supply an options array tells the form helper to
automatically create a select list.

If $this->data['Profile']['group'] is set in the controller (either
manually or from a Model->find call) the form helper will
automatically select it if the value matches a key in your $groups
array.

HTH

Paul

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: