i think the reason why have this error is because of that cake supposes the input is from a multiple-select-box, whose value is an array, but not from a single-select-box (dorp-down-box), whose value is a single string. so when cake tries to read elements from an array but the feed is a string, the error occurs. by default, as grigri said, cake thinks multi-select-box for the habtm relation since you set that there may be many. if this relation is not exactly as expected, i would change it if i were you since there may be more extra database queries (costs) made based on this relation.
good luck! Steve On Apr 16, 6:11 am, Björn Biele <[EMAIL PROTECTED]> wrote: > If I want to save the B's which have/belong to A one by one it is a > proper solution not to use a multiple select box. > > Finally i got the idea using: > > $form->input('Local', array('multiple' => false)) > > could help and it worked! > > The fact that using 'type' => 'select' is producing messed up data > seems pretty weird though to me! > > > Read :http://book.cakephp.org/view/85/saving-related-model-data-habt > > > It describes the proper way to create a habtm form and save the > > related data [especially the last sentence!]. > > > Also, I'm not sure I understand about the multiple-select-box. You've > > defined an assoiciation where `A` has and belongs to *many* `B`, but > > you don't want the select box to be multiple? How does this work? > > > On Apr 16, 1:36 pm, B3 <[EMAIL PROTECTED]> wrote: > >> Hi, > > >> I recently noticed a weird issue regarding the form helper. > > >> I have a model with 2 habtm associations - one of them being 'Local'. > >> So here's what I don't understand: > > >> When using > > >> $form->input('Local') > > >> in an add/edit-form cake's rendering a multiple-select-box, which is > >> not my intention and also space-wasting but working great! > >> So I substituted that line with: > > >> $form->input('Local', array('type' => 'select')) > > >> Cake now renders the desired select-box, but when trying to save the > >> form I get following errors: > > >> Warning (2): Invalid argument supplied for foreach() [CORE/cake/libs/ > >> model/model.php, line 1284] > >> Warning (2): Cannot modify header information - headers already sent > >> by (output started at /path/to/cake/basics.php:338) [CORE/cake/libs/ > >> controller/controller.php, line 546] > > >> The association also doesn't get saved. I can imagine that my post- > >> data is corrupt when using the drop-down-box. Why's that? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---