I have a model Report
, which is related to Account
, and therefore has an account_id
field.
On the Report's edit
method, I have a form with the following field:
echo $this->Form->input('account_id', array(
'div' => 'accountInput',
'options' => $accounts,
'default' => $currentAccountId,
));
(NB: in this case, the 'options' doesn't need to be explictly set thanks to auto-magic)
Now - the real question - if there is an existing value in the database (eg account_id == 1) then even if I include the default
as 2, value 1 still appears as selected in the html form .
I could use a different name for the input, but I want it to save to account_id on submission.
Anyone know how to achieve this simply? (or else I add js and a hidden field or something clunky like that!)
Thanks, A
您可以使用选项'value'而不是'default'。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.