I am adding an additonal field to the customer personal information making use of multi select checkboxes for the user to make his selection. I have it working in the front end, after a bit if a struggle!, but can't get the back office customer form to fully work.
I can collect the the users selection and add it to the database, but I cannot figure out how to populate the customer form with exisiting values when updating, although it works fine with the type = select.
The code in AdminCustomersController.php looks like this:
public function renderForm()
{...........
$this->fields_value['angling_preference[]'] = explode(',',$obj->angling_preference); // Populates the field
$this->fields_form = array(..........
// Checkbox doesn't populate with selection from the database
array(
'type' => 'checkbox',
'name' => 'angling_preference[]',
'label' => $this->l('Type of Angling Preferred (Angling Type):'),
'class' => 'chosen',
'multiple' => true,
'required' => true,
'values' => array(
'query' => $list_angling_preferred,
'id' => 'id',
'name' => 'label'
)
),
// Select works fine with selection from the database
array(
'type' => 'select',
'label' => $this->l('Type of Angling Preferred (Angling Type):'),
'name' => 'angling_preference[]',
'class' => 'chosen',
'multiple' => true,
'size' => '6',
'required' => true,
'options' => array(
'query' => $list_angling_preferred,
'id' => 'id',
'name' => 'label',
'selected' =>'selected'
)
),
The input checkbox works and I can collect the information that is selected and save it to the database, but I can't figure out how to populate it with the previously entered values added from the database.
The input select works fine and populates with data from the database and does everything I need, but it ain't what I want!!!!!
One other small thing, with the input select option the Size = 6 option doesn't work, am I making a syntatical error or if this not supported in Prestashop 1.6?
Many thanks for your help.