Xymor Posted November 20, 2014 Share Posted November 20, 2014 Hi, I cant save value of textarea public function getContent() { if (Tools::isSubmit('submitSomeModule')) { Configuration::updateValue('some_text', Tools::getValue('some_text'), true); } return $this->renderForm(); } protected function renderForm() array( 'type' => 'textarea', 'label' => $this->l('Text field content'), 'name' => 'some_text', 'lang' => true, 'autoload_rte' => true, 'cols' => 60, 'rows' => 30, ), $helper->tpl_vars = array( 'fields_value' => $this->getConfigFieldsValues(), /* Add values for your inputs */ 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id, ); public function getConfigFieldsValues() { return array( 'some_text' => Tools::getValue('some_text', Configuration::get('some_text')), ); } protected function postProcess() { $form_values = $this->getConfigFieldsValues(); foreach (array_keys($form_values) as $key) Configuration::updateValue($key, Tools::getValue($key)); } Link to comment Share on other sites More sharing options...
Xymor Posted November 20, 2014 Author Share Posted November 20, 2014 problem solved Link to comment Share on other sites More sharing options...
Pedro Lima Posted February 13, 2015 Share Posted February 13, 2015 (edited) How did you solved the problem?Problem solved isn't a very friendly/helpful answer. EDIT: Fortunately I could find the problem and here is the explanation for my case (it could be the case for someone else in the future). I will take the code above as example. So, in the code above, there is this: Configuration::updateValue('some_text', Tools::getValue('some_text'), true); And in my case, my code was looking like this: Configuration::updateValue('some_text', (float)Tools::getValue('some_text'), true); So there's (float) which is "Floating point numbers" (for those who want to know more about it go here: http://php.net/manual/en/language.types.float.php ) and that's what was only accepting numbers as input, not allowing me to save text. Edited February 13, 2015 by plima (see edit history) Link to comment Share on other sites More sharing options...
Xymor Posted February 13, 2015 Author Share Posted February 13, 2015 (edited) I don't recall where i had an error but i can post how my code looks now (it won't work with prestashop below 1.6) public function getContent() { if (Tools::isSubmit('submitSOME_MODULE')) { ... Configuration::updateValue('SOME_MODULE_TEXT_FIELD', Tools::getValue('SOME_MODULE_TEXT_FIELD'), true); ... } return $this->renderForm(); } in protected function renderForm() : array( 'type' => 'textarea', 'label' => $this->l('Text field content'), 'name' => 'SOME_MODULE_TEXT_FIELD', 'desc' => $this->l('Text field content.'), 'autoload_rte' => true, 'cols' => 50, 'rows' => 20, ), next: public function getConfigFieldsValues() { return array( .... 'SOMEMODULE_TEXT_FIELD' => Tools::getValue('SOMEMODULE__TEXT_FIELD', Configuration::get('SOMEMODULE__TEXT_FIELD')) ); } protected function postProcess() { $form_values = $this->getConfigFieldsValues(); foreach (array_keys($form_values) as $key) Configuration::updateValue($key, Tools::getValue($key)); } Edited February 13, 2015 by Xymor (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now