Wait, so one field can have multiple values?
You are going to need to manually process your data in your controller
- you can't automatically store multiple values in a single field like
that. You will need to serialize / unserialize (or similar) the data
for the database - I'd suggest doing this in your model beforeSave and
afterFind, but you could do it in your controller action. Secondly,
your view will need to use pseudo fields for each of these checkboxes,
and your controller will need to interpret these.
A crude example of doing it all in a controller action, this is part of
an edit() action:
if(empty($this->data)) {
// show the edit form
$model_row = $this->YourModel->read( null, $id );
// convert the real field into fake fields for the view checkboxes
$checkbox_values = explode( ',', $model_row['YourModel']['your_field']
);
$model_row['YourModel']['fakeField0'] = $checkbox_values[0];
$model_row['YourModel']['fakeField1'] = $checkbox_values[1];
$model_row['YourModel']['fakeField2'] = $checkbox_values[2];
$this->data = $model_row
$this->render();
} else {
// save the submitted data
$this->cleanUpFields();
// convert the fake fields into our real save field
$this->data['YourModel']['your_field'] =
$this->data['YourModel']['fakeField0'].','.$this->data['YourModel']['fakeField1'].','.$this->data['YourModel']['fakeField2'];
if($this->YourModel->save($this->data)) {
and for this, in your view you could have
echo $html->checkbox( 'YourModel/fakeField1' )
etc.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---