Jump to content

Recommended Posts

Hello,

I'm fighting with an issue for updating the configuration of my own module. Pratically when I update the fields in the configuration form in the Admin panel, I got a redirection at the module manager page with the list of all modules installed. I don't understand the reason. I saw the urls printed in the debug console of the browser and there is a GET request at the following url:

http://localhost/prestashop/admin713xxs2gr/index.php?controller=AdminModules&token=57813baf85efd8b05cc49994c243e494&allUpdated=1

the POST request for updating the fields is:

http://localhost/prestashop/admin713xxs2gr/index.php?controller=AdminModules&configure=cookiebanner&token=57813baf85efd8b05cc49994c243e494

Any idea about the reason for this weird behaviour? I made the same stuff in another module and it works correctly. Now I have got no idea about the error.

 

Below there is my code for generating the form:

    public function displayForm()
    {
        // Generate configuration form:

        $fields_form = $this->getConfigForm();

        $helper = new HelperForm();
        $helper->module = $this;
        $helper->name_controller = 'cookiebanner';
        //$helper->table = $this->table; //???
        $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
        $helper->default_form_language = $this->context->language->id;
        $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG', 0);
        $helper->identifier = $this->identifier;
        $helper->fields_value = $this->getConfigFormValues();
        $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false)
            .'&configure='.$this->name;
        $helper->show_cancel_button = true;
        $helper->back_url = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules');
        $helper->token = Tools::getAdminTokenLite('AdminModules');
        $helper->languages = $this->context->controller->getLanguages();
        $helper->default_form_language = (int)$this->context->language->id;

        if(Tools::isSubmit('edit')){
            //$fields_form['form']['submit']['name'] = 'update';
            $helper->submit_action='update';
            $helper->toolbar_scroll = true;
            $helper->toolbar_btn = array(
                'save' => array(
                    'desc' => $this->l('Save'),
                    'href' => $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&update' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules'),
                ),
                'back' => array(
                    'href' => $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules'),
                        'desc' => $this->l('Back to list')
                )
            );

            VarDumper::dump($helper);
            //VarDumper::dump($fields_form['form']['submit']['name']);
        }else{
            $helper->submit_action='save';
            $helper->toolbar_scroll = true;
            $helper->toolbar_btn = array(
                'save' => array(
                    'desc' => $this->l('Save'),
                    'href' => $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&save' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules'),
                ),
                'back' => array(
                    'href' => $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules'),
                        'desc' => $this->l('Back to list')
                )
            );

        }

        return $helper->generateForm(array($fields_form));
    }


    /**
     * Create the structure of your form.
     */
    protected function getConfigForm()
    {
        return array(
            'form' => array(
                'legend' => array(
                    'title' => $this->l('Settings'),
                    'icon' => 'icon-cogs',
                ),
                'input' => array(
                    array(
                        'col' => 3,
                        'type' => 'text',
                        'desc' => $this->l('Enter the header to show into the banner'),
                        'name' => 'header',
                        'label' => $this->l('Header'),
                        'lang' => true,
                    ),
                    array(
                        //'col' => 3,
                        'type' => 'textarea',
                        'desc' => $this->l('Enter the message to show into the banner'),
                        'name' => 'message',
                        'required' => true,
                        'label' => $this->l('Banner Message'),
                        'lang' => true,
                    ),
                ),
                'submit' => array(
                    'title' => $this->l('Save'),
                ),
            ),
            
        );
    }

Thanks in advance for your help.

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More