我想将类别树添加到选择多个选项控件中
我在这上面搜索了很多得到这个链接
但它给了我 ul li 结构的输出,如下所示
但我希望这个树结构选择多个选项
任何人都可以知道如何更改链接代码
准备数组:
public function getCategoriesArray() {
$categoriesArray = Mage::getModel('catalog/category')
->getCollection()
->addAttributeToSelect('name')
->addAttributeToSort('path', 'asc')
->load()
->toArray();
$categories = array();
foreach ($categoriesArray as $categoryId => $category) {
if (isset($category['name']) && isset($category['level'])) {
$categories[] = array(
'label' => $category['name'],
'level' =>$category['level'],
'value' => $categoryId
);
}
}
return $categories;
}
显示形式:
$fieldset->addField('categories', 'multiselect', array(
'label' => $this->__('Categories'),
'name' => 'categories',
'values' => Mage::getModel(...)->getCategoriesArray(),
));