gr4devel Posted May 7, 2013 Share Posted May 7, 2013 (edited) Hi community . I'm trying to reimplement my modules backoffice utilizing the new Helper functions of PS 1.5. I've read the documentation but still I have to get used to these functions and their parameters and in particular to the ones pertaining to the select box options. I can't get the right values displayed in the select box options. The $features variable is just an array or array in which the inner one (i.e. the row) is composed by many fields and "id_feature" is one of them. Actually I want to use this last as the value and the "name" field as the text of the option. $fields_form[0]['form'] = array( 'legend' => array( 'title' => $this->l('Settings'), 'image' => $this->_path.'logo.gif' ), 'input' => array( array( 'type' => 'select', 'label' => $this->l('My field:'), 'name' => 'myfield', 'required' => true, 'options' => array( 'query' => $features, 'id' => 'id_feature' ) ) ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'button' ) ); Thanks in advance to anyone would help me . Edited May 7, 2013 by g11111g (see edit history) Link to comment Share on other sites More sharing options...
gr4devel Posted May 7, 2013 Author Share Posted May 7, 2013 (edited) Ok I was able to get what I need by adding to the 'options' array the 'name' entry and associating it with the actual field of the $features array (i.e. 'name'). Here's just the bit of code that I've changed: 'input' => array( array( 'type' => 'select', 'label' => $this->l('Product vintage feature:'), 'name' => 'vintageFeature', 'required' => true, 'options' => array( 'query' => $features, 'id' => 'id_feature', 'name' => 'name' ) ) ), Sorry for the bother and hopes that this will help someone who face the same problem . Edited May 7, 2013 by g11111g (see edit history) 1 Link to comment Share on other sites More sharing options...
portal7 Posted May 16, 2013 Share Posted May 16, 2013 Thanks!!! this post save my nuts Link to comment Share on other sites More sharing options...
gr4devel Posted May 17, 2013 Author Share Posted May 17, 2013 My pleasure portal7 !!! Link to comment Share on other sites More sharing options...
numerico Posted July 19, 2013 Share Posted July 19, 2013 Thanks too! Link to comment Share on other sites More sharing options...
gr4devel Posted July 19, 2013 Author Share Posted July 19, 2013 You're welcome man ! Link to comment Share on other sites More sharing options...
Bluedge Posted August 22, 2013 Share Posted August 22, 2013 Hi, this doesn't seem to work on version 1.5.1.0. the option list remains empty. Anyone has a work around? Link to comment Share on other sites More sharing options...
realayumi Posted April 6, 2014 Share Posted April 6, 2014 Hello, I can load the option list. But how can we set the "selected" value from the list? Link to comment Share on other sites More sharing options...
XavierPKP Posted October 21, 2014 Share Posted October 21, 2014 Hello, I can load the option list. But how can we set the "selected" value from the list? I need it too, If someone coult help me/us ? Thanks Link to comment Share on other sites More sharing options...
Ornicar Posted November 21, 2014 Share Posted November 21, 2014 Up, Did you find a solution to set the selected value ? I need it too ... Cheer Link to comment Share on other sites More sharing options...
olesho Posted October 6, 2015 Share Posted October 6, 2015 Up, Did you find a solution to set the selected value ? I need it too ... Cheer Ok I was able to get what I need by adding to the 'options' array the 'name' entry and associating it with the actual field of the $features array (i.e. 'name'). Here's just the bit of code that I've changed: 'input' => array( array( 'type' => 'select', 'label' => $this->l('Product vintage feature:'), 'name' => 'vintageFeature', 'required' => true, 'options' => array( 'query' => $features, 'id' => 'id_feature', 'name' => 'name' ) ) ), Sorry for the bother and hopes that this will help someone who face the same problem . Here is the solution for selected value (I continue the example above): $this->fields_value['vintageFeature'] = $default_id_feature; // Here: // 'vintageFeature' is the 'name' of your input // $default_id_feature is the 'id' of the default value 2 Link to comment Share on other sites More sharing options...
hasniou Posted August 30, 2018 Share Posted August 30, 2018 On 06/10/2015 at 3:09 PM, olesho said: Here is the solution for selected value (I continue the example above): $this->fields_value['vintageFeature'] = $default_id_feature; // Here: // 'vintageFeature' is the 'name' of your input // $default_id_feature is the 'id' of the default value Hello, This not work for multiple select. 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