I have a model and hasMany
relation to another model.
The single fields data is saved to the main model, and the data from dropdown select input should be saved to the associated model.
When I'm trying to manually create an array and use saveAll
, everything works fine and the data is saved. But the issue with the select input is inside its name. The correct format is:
array(
'Article' => array('title' => 'My first article'),
'Comment' => array(
array('body' => 'Comment 1', 'user_id' => 1),
array('body' => 'Comment 2', 'user_id' => 12),
array('body' => 'Comment 3', 'user_id' => 40),
),
)
When creating the select list and passing the options array, we can only setone tag name like Comment.body
, but we have to use Comment.0.body
, Comment.1.body
, etc.
So the format of the post data is unreadable for Cake to successfully use saveAll
.
Has anybody encountered this issue - generating multiple select input with correct names and values?