Friday, April 30, 2010

Re: Selected option in select

Sorry for not replying. I had to leave on a very short notice. I will try it again and come back with an update.

On Fri, Apr 30, 2010 at 6:24 PM, Ed Propsner <crotchfrog@gmail.com> wrote:
This also worked: 

$options=array('Generatia 1'=>'Generatia 1','Generatia 2'=>'Generatia 2', 'Generatia 3'=>'Generatia 3');
 echo $form->select('group', $options, array('selected' => 'Generatia 2'));



On Fri, Apr 30, 2010 at 11:22 AM, Ed Propsner <crotchfrog@gmail.com> wrote:
I tried this one and it worked: 

 $options=array('G1'=>'Generatia 1','G2'=>'Generatia 2', 'G3'=>'Generatia 3');
  echo $form->select('group', $options, array('selected' => 'G2'));


On Fri, Apr 30, 2010 at 11:18 AM, Andrei Mita <andrei.mita@gmail.com> wrote:
I saw that right after I sent the e-mail. Now I have:

        $options=array('G1'=>'Generatia 1','G2'=>'Generatia 2', 'G3'=>'Generatia 3');

  
        echo $form->select('group', $options, array('selected' => 'G2'));
        echo $form->select('group', $options, array('selected' => 'Generatia 2'));


None work.



On Fri, Apr 30, 2010 at 6:14 PM, Jeremy Burns <jeremyburns@me.com> wrote:
Could it be the space? Try replacing them both in the options array and the value you are trying to match (tacky I know, but at least it would isolate the problem).


Jeremy Burns

On 30 Apr 2010, at 16:12, Andrei Mita wrote:

I have added the model and there is no change.

I have noticed that if I do the options like 'G1' => 'Generatia 1' and so on, it works.


The debug on $options:

Array
(
[Generatia 1] => Generatia 1
[Generatia 2] => Generatia 2
[Generatia 3] => Generatia 3
[Mesteri] => Mesteri
)





On Fri, Apr 30, 2010 at 6:07 PM, Jeremy Burns <jeremyburns@me.com> wrote:
What about:

$form->select('Profile.group', $options, array('selected' => $this->data['Profile']['group']));

(in other words adding the model name to the select name)


Jeremy Burns


On 30 Apr 2010, at 16:04, Andrei Mita wrote:

I know, I fallowed the example but I'm missing something.


On Fri, Apr 30, 2010 at 6:01 PM, Ed Propsner <crotchfrog@gmail.com> wrote:
I just tried this one and it works : 

$options=array('M'=>'Male','F'=>'Female');
echo $form->select('gender',$options, array('selected' => 'M'));

On Fri, Apr 30, 2010 at 11:00 AM, Andrei Mita <andrei.mita@gmail.com> wrote:
It doesn't work :((



On Fri, Apr 30, 2010 at 5:58 PM, Andrei Mita <andrei.mita@gmail.com> wrote:
I've tried that. I'll try it again. If it works, I'm calling it a day :)



On Fri, Apr 30, 2010 at 5:53 PM, Ed Propsner <crotchfrog@gmail.com> wrote:
Try this. I'm "almost" sure it will work 8-)

$form->select('group', $options, array('selected' => $this->data['Profile']['group']));


On Fri, Apr 30, 2010 at 10:17 AM, Andrei Mita <andrei.mita@gmail.com> wrote:
Hello,

I'm making an edit form and I can't get the existing value to be selected into one of the select field.

The classic input in the view: echo $form->input('group');

I've changed that to a select:

$options=array('Generatia 1'=>'Generatia 1','Generatia 2'=>'Generatia 2', 'Generatia 3'=>'Generatia 3');
echo $form->select('group',$options);

The existing value is in $this->data['Profile']['group'] and, in my example, is equal to "Generatia 2"

How can I make that one selected?

echo $form->select('group',$options, $this->data['Profile']['group']), as shown in the book, doesn't work. What am I missing?

Thanks



Toate cele bune,
Andrei Mita

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



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


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


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

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

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: