tags:

views:

88

answers:

2

in my edit function, i need to reselect for the field again to save it. how can i added a 'selected'=>$addresscountry field in my $form->select function??

this is my code..

echo $country->select('Address.txtother_country','Please Choose Your Country'

which $country is 1 of the helper that include by the page, let user to select country. i need it automatic to refer back to the previous data which had save, means add a selected value in my edit function.

any 1 can help? thanks..

+1  A: 

Hi Vincent,

It'd be useful to see the code for the country helper you've downloaded. There's one called CountryList at http://bakery.cakephp.org/articles/view/country-select-list-helper which seems to do what you want - it may be worthwhile dropping that in.

Cheers JB

James Booker
ya.. i am using that helper as well.. but the problem is in the edit phase... user need to rechoose for the country list to save the data again.. i wanted it to show the data of user had choose when user press edit.
vincent low
A: 

i had found out ther answer, which this link i calling the country helper to view for the country lists.

in the helper header,you will see that is

function select($fieldname, $label, $default=" ", $attributes=array())

just change it's default to the

function select($fieldname, $label, $default, $attributes=array())

and at edit page, just follow the field to put in the element, which is like

echo $country->select('Address.txtother_country','Please Choose Your Country', $addresscountry)

$addresscountry need to find out the data in ur controller and just put at there. if any 1 facing the same problem can have a try, which is using a select country helper, and you wan set the default answer in ur edit page.

vincent low