I'm working with prestashop and try to get value from a form with checkbox using a HelperForm
SO what I had is :
$fields_form[0]['form']= [
'legend'=> [
'title'=> $this->l('Indexation')
] ,
'input'=>[
[
'type'=>'text',
'label'=> $this->l('Base(s) à indexer'),
'name'=>'options',
'size'=>20,
'required'=>true
]
],
'submit'=>[
'title' => $this->l('Save'),
'class' => 'btn btn-default pull-right'
]
];
and then
$helper = new HelperForm();
[...]
$helper->toolbar_btn = array(
'save' =>
array(
'desc' => $this->l('Save'),
'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name.
'&token='.Tools::getAdminTokenLite('AdminModules'),
),
'back' => array(
'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'),
'desc' => $this->l('Back to list')
)
);
// Load current value
$helper->fields_value['options'] = Configuration::get('options');
return $helper->generateForm($fields_form);
and in my getContent
I had :
$my_module_name = strval(Tools::getValue('options'));
return $my_module_name;
So until there I had no problem. I write 'test' in the text input and then 'test' is returned but I don't want a text input I want a checkbox input so I changed my form for :
$fields_form[0]['form']= [
'legend'=> [
'title'=> $this->l('Indexation')
] ,
'input'=>[
[
'type'=>'checkbox',
'label'=> $this->l('Base(s) à indexer'),
'name'=>'options',
'required'=>true,
'values'=>[
'query'=>$options,
'id'=>'id',
'name'=>'name'
]
]
],
'submit'=>[
'title' => $this->l('Save'),
'class' => 'btn btn-default pull-right'
]
];
and in my getContent()
: return (Tools::getValue('options'));
But with that, nothing is displayed.
Aucun commentaire:
Enregistrer un commentaire