Prestashop 1.6 - Create forms with more than 1 submit button

I am trying to implement a form in a tab in the back office in prestashop 1.6.

I managed to create a form using the Helper class and everything works fine. However, from what I can see, the helper class only allows the Submit button. For my needs, I need to use more than 1 that do different things in the postProcess () part of the controller. Any help in achieving this 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));
        }

      

+3


source to share


1 answer


You can create other shapes on the same screen.

return $helper->generateForm(array($fields_form1, $fields_form2, $fields_form3));

      



Or, if you really need to reuse the same form, you can add <select>

as the last element of the form, which will give you a choice of the action to be taken by the submit button.

+2


source







All Articles