Nicks Posted September 29, 2017 Share Posted September 29, 2017 Hi! I need to add a dropdown menu to homeslider. I've added it in homeslide.php and homeslider.php, based on "helper forms" and it works fine in displaying the field in admin form and registering values in the db : homeslider.php : array( 'type' => 'select', 'label' => $this->l('categorie'), 'name' => 'category', 'required' => true, 'options' => array( 'query' => $options = array( array( 'id_option' => 'cat1', // The value of the 'value' attribute of the <option> tag. 'name' => 'Catégorie 1' // The value of the text content of the <option> tag. ), array( 'id_option' => 'cat2', 'name' => 'Catégorie 2' ), ), 'id' => 'id_option', 'name' => 'name' ) ), Problem is, the "selected" state of the field is not working (when i try to update a slide, the value in db isn't selected). I've tested the vars in the tpl (based on : {extends file="helpers/form/form.tpl"}) : {if $fields_value[$input.name] == $option[$input.options.id]} selected="selected" {/if} The value of $option[$input.options.id] is fine, but the value of $fields_value[$input.name] isn't what is expected... It's a number '1' (for every option, when it should be the id_option string of the array. Thanks for help Link to comment Share on other sites More sharing options...
Nicks Posted September 29, 2017 Author Share Posted September 29, 2017 Ok, i had (at least) a mistake... So $fields_value[$input.name] value is now array. So, i think problem is that i can't access the value of an array, this way : $fields['category'] = Tools::getValue('category', $slide->category); Anyone knows how i get the value of an array, please? Thank you 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