Just check which of those checkboxes have been checked, and for those which
weren't unset the appropriate $this->data field before calling
model->save(). For example if you have a checkbox named Post/check_title to
allow user to specify if the field Post/title should be saved then it should
be something like:

if (!empty($this->data))
{
        if (!isset($this->data['Post']['check_title']) ||
$this->data['Post']['check_title'] != 1)
        {
                unset($this->data['Post']['title']);
        }

        // Some more...

        $this->Post->save($this->data);
}

This way only checked fields will be sent to save(). Beware of mandatory
field validation, though.

-MI

---------------------------------------------------------------------------

Remember, smart coders answer ten questions for every question they ask. So be smart, be cool, and share your knowledge.
BAKE ON!


-----Mensaje original-----
De: [email protected] [mailto:[EMAIL PROTECTED] En nombre
de simacole
Enviado el: Lunes, 01 de Enero de 2007 11:16 p.m.
Para: Cake PHP
Asunto: How can I modify fields on different rows with one form.


A complete NewB question here. In a lot of the basic tutorials there
are examples of forms that modify one record in a database table.
However, what I can't see to get my brain around is how, using the html
checkbox helper, I can create a form that allows me to modify one field
on different rows. Basically, the user should be able to click
checkboxes in a single view and on submit have them update the fields
in the respective rows on the database.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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