herwaldi Posted June 22, 2022 Share Posted June 22, 2022 (edited) Hello everyone, How to select an active option in my module? checked options dont work return array( 'form' => array( 'legend' => array( 'title' => $this->l('Choose products'), 'icon' => 'icon-th-large', ), 'input' => array( array( 'type' => 'select', 'label' => $this->l('Products available with a gift'), 'name' => 'selectProductsField', 'class' => 'selectProducts', 'required' => false, 'col' => 5, 'multiple' => true, 'options' => array( 'query' => ProductGiftProduct::getProducts(true), 'id' => 'id_product', 'name' => 'name', 'checked' => 597, ) ), ), 'submit' => array( 'title' => $this->l('Save'), ), ), ); Edited June 22, 2022 by herwaldi wrong code (see edit history) Link to comment Share on other sites More sharing options...
abdullacm Posted June 22, 2022 Share Posted June 22, 2022 you should pass the value using "fields_value" as below $helper->tpl_vars = array( 'uri' => $this->getPathUri(), 'fields_value' => $this->getConfigFieldsValues(), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id ); here, getConfigFieldsValues should return an associative array with field name, value pair function getConfigFieldsValues() { return array( 'selectProductsField' => 597 ); } 1 Link to comment Share on other sites More sharing options...
herwaldi Posted June 23, 2022 Author Share Posted June 23, 2022 13 hours ago, abdullacm said: you should pass the value using "fields_value" as below $helper->tpl_vars = array( 'uri' => $this->getPathUri(), 'fields_value' => $this->getConfigFieldsValues(), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id ); here, getConfigFieldsValues should return an associative array with field name, value pair function getConfigFieldsValues() { return array( 'selectProductsField' => 597 ); } thank you ❤️ 1 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