I need to add more than one category trees to a module form. While trying to do so, I see all the trees appearing in the output, however the other trees do not function properly. A deeper look revealed that the other rendered trees are taking the same id specified for the first one.
Below is the piece of the input array
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Block Name'),
'name' => 'block_name'
),
array(
'type' => 'categories',
'label' => $this->l('Root category'),
'name' => 'id_root_category',
'tree' => array(
'id' => 'id_root_category',
)
),
array(
'type' => 'categories',
'label' => $this->l('Exclude categories'),
'name' => 'exclude_cats',
'tree' => array(
'id' => 'exclude_cats',
'use_checkbox' => true
),
),
...
...
)
The helperForm class does not seem to allow more than one such trees by its code. The use of $categories variable is controlling the number of tree per form. You can see that below.
case 'categories':
if ($categories)
{
$tree = new HelperTreeCategories($params['tree']['id'], isset($params['tree']['title']) ? $params['tree']['title'] : null);
if (isset($params['name']))
$tree->setInputName($params['name']);
if (isset($params['tree']['selected_categories']))
$tree->setSelectedCategories($params['tree']['selected_categories']);
if (isset($params['tree']['disabled_categories']))
$tree->setDisabledCategories($params['tree']['disabled_categories']);
if (isset($params['tree']['root_category']))
$tree->setRootCategory($params['tree']['root_category']);
if (isset($params['tree']['use_search']))
$tree->setUseSearch($params['tree']['use_search']);
if (isset($params['tree']['use_checkbox']))
$tree->setUseCheckBox($params['tree']['use_checkbox']);
$this->context->smarty->assign('categories_tree', $tree->render());
$categories = false;
}
break;
Does anyone have any solution?