Instead of forcing a selected item in the view like that, you should
provide a default value in your controller.
either:
$this->data['Model']['fieldname'] = 'default';
or:
$this->Model->create();
$this->data = $this->Model->data;
This second one will get the default values as specified by your
database table. Of course, only do either of these where you are not
loading an existing row, and not re-showing the posted data.
On Sep 17, 6:12 am, Claudia <[EMAIL PROTECTED]> wrote:
> Hi here
>
> I have a few selectboxes where the default value is not the first
> option.
> Thus I provide an option 'selected', e.g.
> $this->Form->input('Model.fieldname', array('options' => range(0, 23),
> 'selected' => 7))
> The problem is that when I submit the form and get it back with $this->data
> being set the selectboxes are still set to the default value,
>
> not to the value set in $this->data.
>
> As a quick workaround I have changed the code in FormHelper::select
> but I am wondering whether I am just missing the correct way to use
> the select helper.
>
> I use Cake 1.2
>
> Thanks for any tips
>
> Claudia
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---