On Wed, Mar 23, 2011 at 8:25 PM, OldWest <[email protected]> wrote:
> I am trying to pre-populate this State select box with the existing
> selection when editing records. in a related model.
>
> plan_details/view.ctp
>
> echo $this->Form->input('State',array('empty' => false,'options' =>
> $state));
>
> plan_details_controller view function:
>
> $state = $this->PlanDetail->Plan->State->find('list');
>     $this->set(compact('state', $state));
>     debug($state);
>
> Array output in view.ctp (as expected):
>
> Array
> (
>     [1] => Oregon
>     [2] => Washington
> )
>
> My select box above defaults to 1 in the array. I need it to default to the
> already existing selected value.
>
> For example, when I added a record and a selected Washington(2), then when
> viewing my edit screen, the pre-selected value should be Washington with
> value 2.
>
> I'm stuck and cracking at this for a while. Any idea what I am doing wrong?

echo $this->Form->input('Plan.state_id' ...

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to