Re: Problems saving with hasAndBelongsToMany (multi_field)

2008-04-15 Thread gmwebs
Oh great... good news. Incidentally, what version of Cake are you using? I think this relates to https://trac.cakephp.org/ticket/3814 but it should have been fixed already... I am using the nightly build which is probably why I wasn't seeing this in my tests. PS - I'll have a pint of Guinness ple

Re: Problems saving with hasAndBelongsToMany (multi_field)

2008-04-15 Thread MonkeyGirl
Ah, someone else has just e-mailed me with the fix, namely inserting this line: $newValues = array(); ...before line 1283 of /cake/libs/model/model.php. Phew! If either of you are ever in the UK, let me buy you both a drink. :) Thank you both very much, Zoe. --~--~-~--~~---

Re: Problems saving with hasAndBelongsToMany (multi_field)

2008-04-15 Thread gmwebs
Progress at least then ;) Is it not maybe the following code in your view: if (isset($this->data[$modelName]['id'])) { echo $form->input('id'); } That is the only block I didn't include in my test. --~--~-~--~~~---~--~~ You received this message because y

Re: Problems saving with hasAndBelongsToMany (multi_field)

2008-04-15 Thread MonkeyGirl
That's really odd... $this->data looks fine for my project now too... Array ( [Product] => Array ( [id] => 6 [name] => Classic Men's Parka ) [Category] => Array ( [Category] => Array ( [0] =>

Re: Problems saving with hasAndBelongsToMany (multi_field)

2008-04-15 Thread gmwebs
Ok... I have used your view code and it works just fine. I get the following... Array ( [Product] => Array ( [name] => gloves ) [Category] => Array ( [Category] => Array ( [0] => 1 )

Re: Problems saving with hasAndBelongsToMany (multi_field)

2008-04-15 Thread MonkeyGirl
OK, here's the complete view. I would suspect I've stumbled across a CakePHP bug to do with having multiple multi tickboxes in the same form, but I'm hesitant to draw such hasty conclusions - in the past it's always been a bug of my own. create(); if (isset($this->data[$modelName]['id'])) {

Re: Problems saving with hasAndBelongsToMany (multi_field)

2008-04-15 Thread gmwebs
How does the $this-data look now? In my add view, all I am doing is: create('Product');?> input('name'); echo $form->input('Category'); echo $form->input('Color'); echo $form->input('Size'); ?> end(

Re: Problems saving with hasAndBelongsToMany (multi_field)

2008-04-15 Thread MonkeyGirl
Thanks, that makes sense. So to get the data into a format like it is in your example, I've reverted back to how I was making the form earlier. Instead of adding multiple type elements like this: echo $form->input('Category.multi_field', array( 'options' => $categories, 'label' => 'Categories

Re: Problems saving with hasAndBelongsToMany (multi_field)

2008-04-14 Thread gmwebs
I wasn't able to get that script of yours to work, so I set a test up quickly. If I add a product and select the different multi_fields I get this as my $this->data: Array ( [Product] => Array ( [name] => socks ) [Category] => Array ( [Cate

Re: Problems saving with hasAndBelongsToMany (multi_field)

2008-04-14 Thread MonkeyGirl
OK, whatever I'm doing wrong, it's probably the exact same thing I'm doing wrong with this code (I've put it public before it's working in case it helps you help me fix my bug at all): Tarball: http://cakephp.bytenoise.co.uk/simple-blog-example.tbz SQL: http://cakephp.bytenoise.co.uk/#creating_a

Re: Problems saving with hasAndBelongsToMany (multi_field)

2008-04-14 Thread MonkeyGirl
> Oh, interesting... Yeah, I'll be happy to include it in my publicly shared code just as soon as I can get the thing working. :) > How about a full output of $this->data then? I know I have had > problems saving if the array is not in the correct order. i.e. If you > try to do $this->Product->s

Re: Problems saving with hasAndBelongsToMany (multi_field)

2008-04-14 Thread gmwebs
Oh, interesting... How about a full output of $this->data then? I know I have had problems saving if the array is not in the correct order. i.e. If you try to do $this->Product->save() then the Product array should appear first in $this->data. Have you turned debug on to 2 - if you have then is i

Re: Problems saving with hasAndBelongsToMany (multi_field)

2008-04-14 Thread MonkeyGirl
> Hi Zoe, could you post the controller code? The thing is it's all in app_controller. I've made a scoffolding-esque set of admin pages that apply to pretty much every model. After checking the user's an admin, it works out the controller name, model name, checks if $this->data is empty, then sav

Re: Problems saving with hasAndBelongsToMany (multi_field)

2008-04-14 Thread gmwebs
Hi Zoe, could you post the controller code? --~--~-~--~~~---~--~~ 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 t

Problems saving with hasAndBelongsToMany (multi_field)

2008-04-14 Thread MonkeyGirl
Hi. I'm using this spiffy new automatically-generating-multiple-tickboxes part of the form helper like this: echo $form->input('Colour.multi_field', array( 'options' => $colours, 'label' => 'Colours', 'multiple' => 'checkbox', 'error' => array( 're