Re: default value for selectbox overrides posted data

2007-09-17 Thread Claudia

Thank you for your answers.

Using 'default' => value in the array does not work,
it looks like this is not used for selectboxes

I'll just set the default value in the controller.

Claudia


On Sep 17, 1:00 am, Grant Cox <[EMAIL PROTECTED]> wrote:
> 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 cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: default value for selectbox overrides posted data

2007-09-16 Thread Grant Cox

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 cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: default value for selectbox overrides posted data

2007-09-16 Thread francky06l

try to add 'default' => value in the array()

Sep 16, 10:12 pm, 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 cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



default value for selectbox overrides posted data

2007-09-16 Thread Claudia

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 cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---