Galaron Posted July 31, 2014 Share Posted July 31, 2014 Hi all, I'm facing a problem with the HelperForm and an input of password type: I'm developing a module for PrestaShop 1.6 with Bootstrap support and in my renderForm() method I declare my form fields like this: $fields_form[0]['form'] = array( 'legend' => array( 'title' => $this->l('Settings'), 'icon' => 'icon-cogs' ), 'input' => array( // All my fields here ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'button pull-right' ) ); One of these fields is an input of type password and I've declared it like this: array( 'type' => 'password', 'label' => $this->l('Password'), 'desc' => $this->l('My pwd description'), 'name' => 'MY_PASSWORD', 'required' => true ) And at the end of same method, just before the return statement, I load the current value like this: $helper->fields_value['MY_PASSWORD'] = Configuration::get('MY_PASSWORD'); The problem is that when I enter in the configuration page of my module, the password field is rendered with the Bootstrap nice CSS, but it is always empty. If I write inside it and then I save settings it works (I mean I get no error) but when page reload that field is empty again. If I change is type as a common text field like this: array( 'type' => 'text', 'label' => $this->l('Password'), 'desc' => $this->l('My pwd description'), 'name' => 'MY_PASSWORD', 'required' => true ) the problem vanish and it work as intended. Thanks you all for your time and attention. Link to comment Share on other sites More sharing options...
El Patron Posted July 31, 2014 Share Posted July 31, 2014 without testing, try changing 'name' => 'MY_PASSWORD', to 'name' => 'passwd', validate object looks specifically for passwd and processes accordingly. Link to comment Share on other sites More sharing options...
Galaron Posted July 31, 2014 Author Share Posted July 31, 2014 (edited) Mmh, doesn't work. Field is rendered but stays empty when I enter module configuration page. Edited July 31, 2014 by Galaron (see edit history) Link to comment Share on other sites More sharing options...
Galaron Posted August 1, 2014 Author Share Posted August 1, 2014 Up Link to comment Share on other sites More sharing options...
Galaron Posted August 1, 2014 Author Share Posted August 1, 2014 Up Link to comment Share on other sites More sharing options...
numberMumbler Posted October 19, 2014 Share Posted October 19, 2014 (edited) Seems like the field was designed to behave this way: you can only use the field to change a password... it never displays anything. So, you'll want to check for a value before updating the password field I'm using something like this: $password = strval(Tools::getValue('myPasswordId')); if($password) { // only save if a value was entered Configuration::updateValue('passwordKey', $password); } Note: the password field shouldn't be "required", because it's only for updating. It would be nice for the field to show something by default instead of just giving you an empty field. I might look into that when I get some time. Edited October 19, 2014 by numberMumbler (see edit history) 1 Link to comment Share on other sites More sharing options...
Recommended Posts