acceder les checboxes d'un embedded form
Hi,
Desole, le message est en anglais... Je suis n nouvel utilisateur de symfony et j'ai besoin d'aide urgente.
I have been trying for days to access checkboxes of an embedded form and it's driving me crazy. I just can not do it and I wonder if it is possible at all.
For info, the data I need to save in a DB field must be formatted as follows: value1|value2|value3
value1, value2, value3 being my checkboxes values.
Currently when saving, it writes 'Array' in the DB field.
I need to be able to load and save the data.
In my main form I have
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
class EditLandingProfilingForm extends BaseUserForm
{
public function configure()
{
...
foreach($this->getObject()->getCustomerMaster() as $cusVal){
$this->embedForm('editcustomer', new EditCustomerProfilingForm($cusVal));
if($cusVal->getCategoriesInterest()){
$avail = explode('|', $cusVal->getCategoriesInterest());
$this->setDefault('editcustomer[categories_interest]', $avail);
}
}
} |
but it does not work.
I do have other values that get displayed properly in my form but they are text field.
When saving the form, I have the same problem. I need to make the array of posted checkboxes become a string (value1|value2|value3)
but once again I can not access the posted values and update them before they are saved in DB.
my code is as follow for declaring the form
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
$data = Doctrine::getTable('User')->checkUsername($username);
if ($data){
$customer = $data->getCustomerMaster();
$this->form = new EditLandingProfilingForm($data);
}
if ($request->isMethod('post'))
{
$this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
$this->form_data = $request->getParameter($this->form->getName());
if ($this->form->isValid()) {
/* I NEED TO EDIT SOMEWHERE THE POSTED DATA SO IT READS value1,value2... */
$this->form->save();
}
} |
I hope it makes sense.
Any healp would be greatly appreciated.