I have Clusters hasMany Companies.

In Clusters controller I have this:
        $this->set('companies',$this->Cluster->Company->find('list'));

In my Clusters Edit View I have this:

        echo $form->input('id');
        echo $form->input('name');
        echo $form->input('Company',array('multiple'=>'checkbox'));


Observations:

1) in my edit view above, I see multiple checkboxes (Label name(which
is Company.company_name) and checkbox next to it - this is all done
automatically by cakephp). If Company was set for this specific
Cluster (if in DB Company.cluster_id is set to this Cluster.id), I see
it's checkbox checked.

2) If create an intermediate table and set Clusters
hasAndBelongsToMany Companies, above code works like a charm

PROBLEM:
Above code doesn't save checkboxes. When I check/uncheck Companies, it
says data saved, but actually it is not being saved (the checkboxes
part); if I change name for Cluster - it gets saved.

PS: http://book.cakephp.org/view/1031/Saving-Your-Data --> under
saveAll() it mentions something like "echo $form->input('Account.
0.username');", but how to make it work for multiple checkboxes like I
have, and so that selected checkboxes are also shown.

When form is submitted, array with checked IDs is submitted to
controller, so I could drop all prev values and update companies using
this new array, but that's a bit ugly and isn't cakish.. How to
achieve it using cakephp?

Any help is appreciated.
- Muhammed

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to