Jump to content

How to create select with optgroup in renderForm() (PS version 1.5.6.0)


Recommended Posts

Anybody know how to create a select with optgroup in function renderForm() and $this->fields_form?
I have a multiple select, and i need create section in select to split products (split by store or category):

 

$this->fields_form = array(
  'tinymce' => true,
  'legend' => array('title' => $this->l('Page')),
  'input' => array(
    array(
      'type' => 'text',
      'label' => $this->l('Name'),
      'name' => 'name',
      'lang' => true,
      'required' => true,
      'hint' => $this->l('Invalid characters:').' <>;=#{}',
    ),     
    array(
      'type' => 'select',
      'label' => $this->l('Products'),
      'name' => 'id_products[]',
      'required' => false,
      'col' => '4',
      'default_value' => null,
      'multiple' => true,
	  'options' => array(
        'query' => Product::getProducts($this->context->language->id, 0, 6000, 'name', 'asc'),
        'id' => 'id_product',
        'name' => 'name'
      )
    )
  ),
  'submit' => array('title' => $this->l('Save'))
);

 

Thanks for help.

Edited by zebenplexus (see edit history)
Link to comment
Share on other sites

  • 1 month later...
'input' => array(
    array(
        'type' => 'select',
        'label' => 'select product one',
        'name' => 'type_select_chosen',
        'class' => 'chosen',
        'options' => array(
            'optiongroup'=>array(
                'label'=>'label',
                'query'=>array(array(
                        'label'=>'marg',
                        'options'=>array(
                                array('id'=>1,'name'=>'one'),
                                array('id'=>2,'name'=>'two'),
                                array('id'=>3,'name'=>'three'))
                )),

            ),
             'options'=>array(
                 'query'=>'options',
                 'id'=>'id',
                 'name'=>'name'
                 )
        ),
        ),
),
  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Hi,

I know this post is not very young, but... Do you know if this works in Prestashop 1.7.6.4 ?


I need to do exactly the same thing, but I have no idea how to do this and where to put it ?
thanks for the feed back !

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...