Jump to content

Edit History

Minsky_ae

Minsky_ae

Hello there,

I would like to create a custom module where I can display a list of available categories and be able to select multiple ones to then use them on front.

I used @ovy79ro code to display the list in back-office but I'll be glad to have some help to go further:

1. List is collapse by default, how can I expand it by default?

2. I used the checkbox property but I've got radio button and can select only one category instead of multiple ones

array(
  'type'  => 'categories',
  'label' => $this->l('Product Category'),
  'name'  => 'FEATURED_CATEGORIES',
  'tree'  => array(
    'id' => 'category',
    'selected_categories' => array((int)Configuration::get('category')),
  ),
  'use_checkbox' => true
),

3. I'm not sure how I'm suppose to save the selected categories, how to get selected categories in getConfigFormValues()?

protected function postProcess()
{
  $form_values = $this->getConfigFormValues();

  foreach (array_keys($form_values) as $key) {
    Configuration::updateValue($key, Tools::getValue($key));
  }
}

Thanks a lot for any help!

Minsky_ae

Minsky_ae

Hello there,

I would like to create a custom module where I can display a list of available categories and be able to select multiple ones to then use them on front.

I used @ovy79ro code to display the list in back-office but I'll be glad to have some help to go further:

1. List is collapse by default, how can I expand it by default?

2. I used the checkbox property but I've got radio button and can select only one category instead of multiple ones

array(
  'type'  => 'categories',
  'label' => $this->l('Product Category'),
  'name'  => 'FEATURED_CATEGORIES',
  'tree'  => array(
  'id' => 'category',
  	'selected_categories' => array((int)Configuration::get('category')),
  ),
  'use_checkbox' => true
),

3. I'm not sure how I'm suppose to save the selected categories, how to get selected categories in getConfigFormValues()?

protected function postProcess()
{
  $form_values = $this->getConfigFormValues();

  foreach (array_keys($form_values) as $key) {
    Configuration::updateValue($key, Tools::getValue($key));
  }
}

Thanks a lot for any help!

Minsky_ae

Minsky_ae

Hello there,

I would like to create a custom module where I can display a list of available categories and be able to select multiple ones to then use them on front.

I used @ovy79ro code to display the list in back-office but I'll be glad to have some help to go further:

1. List is collapse by default, how can I expand it by default?

2. I used the checkbox property but I've got radio button and can select only one category instead of multiple ones

array(
  'type'  => 'categories',
  'label' => $this->l('Product Category'),
  'name'  => 'FEATURED_CATEGORIES',
  'tree'  => array(
  'id' => 'category',
  	'selected_categories' => array((int)Configuration::get('category')),
  ),
  'use_checkbox' => true
),

I'm not sure how I'm suppose to save the selected categories, how to get selected categories in getConfigFormValues()?

protected function postProcess()
{
  $form_values = $this->getConfigFormValues();

  foreach (array_keys($form_values) as $key) {
    Configuration::updateValue($key, Tools::getValue($key));
  }
}

Thanks a lot for any help!

Minsky_ae

Minsky_ae

Hello there,

I would like to create a custom module where I can display a list of available categories and be able to select multiple ones to then use them on front.

I used @ovy79ro code to display the list in back-office but I'll be glad to have some help to go further:

1. List is collapse by default, how can I expand it by default?

2. I used the checkbox property but I've got radio button and can select only one category instead of multiple ones

array(
  'type'  => 'categories',
  'label' => $this->l('Product Category'),
  'name'  => 'FEATURED_CATEGORIES',
  'tree'  => array(
  'id' => 'category',
  	'selected_categories' => array((int)Configuration::get('category')),
  ),
  'use_checkbox' => true
),

I'm not sure how I'm suppose to save the selected categories (even with just one selected, it didn't save it in Configuration table).

/**
 * Set values for inputs.
 */
protected function getConfigFormValues()
{
  return array(
    'FEATURED_CATEGORIES' => Configuration::get('FEATURED_CATEGORIES', '')
  );
}

/**
 * Save form data.
 */
protected function postProcess()
{
  $form_values = $this->getConfigFormValues();

  foreach (array_keys($form_values) as $key) {
    Configuration::updateValue($key, Tools::getValue($key));
  }
}

Thanks a lot for any help!

×
×
  • Create New...