Not 100% sure it works when you go directly to html->select but I know
it works for input.

There is the manual way:

$form->input('Modelname.fieldname', array(
        'type'=>'select',
        'options'=>$list,
        'value'=>$your_selected_value
));

But the magic of Cake can do for you is where I might be wrong on the
syntax:

$this->set('fielnames',$this->Modelname->getlist
(null,'id',null,'{n}.id','{n}.name');
---
$form->input('Modelname.fieldname', array(
        'type'=>'select'
));

That is: if you set a view variable to the same as your fieldname OR
the fieldname in plural (not sure there) Cake should pick up the
"vaule" from $this->data['Modelname']['fieldname'] and the "options"
from the set variable.

Try it, but please check for it in the manual or in some previous
thread here.

/Martin


On Sep 3, 12:11 pm, DatacenterHellas <[email protected]> wrote:
> Hello ! ! !
>
> I need your help please :)
>
> I try to load a list into a select option control by doing to
>
> [ Controller ]
>
> function edit()
> {
>   $this->set('list',$this->Modelname->getlist
> (null,'id',null,'{n}.id','{n}.name');
>
> }
>
> [ View ]
>
> $form->select('Modelname.fieldname',$list);
>
> now how can I add the attribute selected="selected" to one of the
> options that the above code generates ? ? ?
>
> Kind regards
> Merianos Nikos
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to