prestashop_newuser Posted August 19, 2014 Share Posted August 19, 2014 Hi, In a module I want to show a checkbox checked by default. For that I just took the helper class methods like this $display_settings = array( 'form' => array( 'legend' => array( 'title' => $this->l( 'Display Settings' ), 'icon' => 'icon-cogs' ), 'input' => array( array( 'type' => 'checkbox', 'name' => 'display', 'values' => array( 'query' => array( array( 'id' => 'show_header', 'name' => $this->l('show'), 'val' => '1', 'checked' => 'checked' ), ), 'id' => 'id', 'name' => 'name' ) ), ), 'submit' => array( 'title' => $this->l( 'Save Settings' ), 'class' => 'button pull-right', 'name' => 'save-settings', ) ), ); but this one is showing only checkbow (not checked). I tried to chnage val into 0,1. But it did not worked for me. So can someone tell me how to make a checkbox checked in helper class. Any help or suggestions will be really appreceable. Thanks Link to comment Share on other sites More sharing options...
shacker Posted November 12, 2014 Share Posted November 12, 2014 check the watermark module. works as example for checked values 1 Link to comment Share on other sites More sharing options...
Azoda.net Posted November 25, 2014 Share Posted November 25, 2014 like your problem,do you solved that ? prestashop_newuser, tell me what should I do ? 2 Link to comment Share on other sites More sharing options...
shacker Posted November 25, 2014 Share Posted November 25, 2014 like your problem,do you solved that ? prestashop_newuser, tell me what should I do ? in the watermark module you cand find the code to get a checked value Link to comment Share on other sites More sharing options...
Klemart3D Posted July 18, 2016 Share Posted July 18, 2016 @prestashop_newuser, to solve your (old) post : Remove your `'checked' => 'checked'` Add this code below yours : $helper = new HelperForm(); $helper->fields_value['save-settings_show_header'] = 'true'; return $helper->generateForm(array($display_settings)); The "save-settings_show_header" is a auto-Prestashop's concatenation of your form's group name "save-settings" and option's id "show_header". In place of "true", you can use "1" to set checkbox as checked (or "false" or "0" to keep it unchecked). Solution found here : http://stackoverflow.com/questions/25379126/prestashop-show-helper-form-checkbox-checked Link to comment Share on other sites More sharing options...
Azoda.net Posted July 21, 2016 Share Posted July 21, 2016 I solved itthis is my example on helper form $picking_history = array(array('id'=>'history_1', 'name' => '', 'val' => '1')); array( 'type' => 'checkbox', 'label' => $this->l('Display history block on order page'), 'name' => 'SHOW_HISTORY', 'values' => array( 'query' =>$picking_history, 'id' => 'id', 'name' => 'name', 'value' => '1' ), 'tab' => 'config', ),in getConfigFormValues function I return array( 'PICKINGCART_HISTORY_history_1' => Configuration::get('PICKINGCART_HISTORY'), );and It working now 1 Link to comment Share on other sites More sharing options...
Recommended Posts