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 (e.g. 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