Hi Luke,
Yes the problem is that your data array is not in the right format.
The manual is pretty clear on the hasMany format (for your
ingredients) ... (http://book.cakephp.org/view/75/Saving-Your-Data)
but the format for the habtm model is not so obvious... if you are
attaching multiple subcategories from your view using say a checkbox,
you would set a variable to a list of subcategories in your controller
like: $subcategories=$this->Subcategory->find('list')
and then in your view if you put:
$form->input('Subcategory.Subcategory',array
('type'=>'select','multiple'=>'checkbox')
the data will be returned in the right format for save to
automatically save the lot: something like this:

Array(
    Recipe=>Array(...)
    Ingredient=>Array(
        [0]=>Array('ingredientname'=>'meat'),
        [1]=>Array('ingredientname'=>'pepper),
        [2]=>...
    )
    Subcategory=>Array(
        Subcategory=>Array(
            [0]=>'id1',
            [1]=>'id2',
            ....
       )
    )
)



On Aug 14, 7:39 pm, Luke <[email protected]> wrote:
> Hi,
>
> Sorry that I have to get back again. I am still hanging on this
> issue.
>
> recipe HABTM subcategories
> recipe hasMany ingredients
>
> My $this->data array
>
> Array
> (
>     [Recipe] => Array
>         (
>             [id] => 6
>             [RecipeUIED] =>
>             [recipe_name] => Testname
>          )
>
>     [Ingredient] => Array
>         (
>             [ingredientname] => Array
>                 (
>                     [0] => water
>                     [1] => meat
>                     [2] => salt
>                     [3] => pepper
>                 )
>
>         )
>
>         [Subcategory] => Array
>         (
>             [checkbox] => Array
>                 (
>                     [1] => 1
>                     [2] => 0
>                 )
>
>         )
>
> Is the Array correct formated or what is wrong? saveAll does not want
> to save everything.
> INSERT INTO `ingredients` (`ingredientname`) VALUES (Array)
>
> So, $this->Recipe->saveAll($this->data) does not seem to work. How can
> I save the hasMany and HABTM relationship than?
> I tried to implement Persivo's hint, but was not successfull either.
> Any hint is much appreciate, since I don't seem to move any step.
>
> Thanks a lot in advance. Luke
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to