07-26-2023, 03:07 PM
I'm trying to implement a form in a tab on the back office on prestashop 1.6.
I've succeeded creating the form using the Helper class and all works fine. However, of what I see the helper class only allows 1 submit button. For my needs I need to use more than 1 that perform different actions on the postProcess() part of the controller. Any help on achieving that would be much appreciated. Here is my render form that works with a single submit button:
public function renderForm()
{
$fields_form = array(
'form' => array(
'legend' => array(
'title' => $this->l('Contact details'),
'icon' => 'icon-envelope'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Account owner'),
'name' => 'BANK_WIRE_OWNER',
),
array(
'type' => 'textarea',
'label' => $this->l('Details'),
'name' => $this->l('test2'),
'desc' => $this->l('Such as bank branch, IBAN number, BIC, etc.')
),
array(
'type' => 'textarea',
'label' => $this->l('Bank address'),
'name' => 'BANK_WIRE_ADDRESS',
),
),
'submit' => array(
'title' => $this->l('Save'),
)
),
);
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table = $this->table;
$lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
$helper->default_form_language = 1;
$helper->fields_value['BANK_WIRE_OWNER'] = "";
$helper->fields_value['test2'] = "";
$helper->fields_value['BANK_WIRE_ADDRESS'] = "";
$this->fields_form = array();
$helper->submit_action = 'test';
return $helper->generateForm(array($fields_form));
}
I've succeeded creating the form using the Helper class and all works fine. However, of what I see the helper class only allows 1 submit button. For my needs I need to use more than 1 that perform different actions on the postProcess() part of the controller. Any help on achieving that would be much appreciated. Here is my render form that works with a single submit button:
public function renderForm()
{
$fields_form = array(
'form' => array(
'legend' => array(
'title' => $this->l('Contact details'),
'icon' => 'icon-envelope'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Account owner'),
'name' => 'BANK_WIRE_OWNER',
),
array(
'type' => 'textarea',
'label' => $this->l('Details'),
'name' => $this->l('test2'),
'desc' => $this->l('Such as bank branch, IBAN number, BIC, etc.')
),
array(
'type' => 'textarea',
'label' => $this->l('Bank address'),
'name' => 'BANK_WIRE_ADDRESS',
),
),
'submit' => array(
'title' => $this->l('Save'),
)
),
);
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table = $this->table;
$lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
$helper->default_form_language = 1;
$helper->fields_value['BANK_WIRE_OWNER'] = "";
$helper->fields_value['test2'] = "";
$helper->fields_value['BANK_WIRE_ADDRESS'] = "";
$this->fields_form = array();
$helper->submit_action = 'test';
return $helper->generateForm(array($fields_form));
}