joomla 2.5保存多个选择列表?

时间:2012-05-25 01:02:54

标签: joomla selectlist multiple-select

我正在尝试向我的后端组件添加多个选择列表,但我似乎无法让它工作。我已经尝试搜索joomla论坛,并尝试了他们的建议,但它仍然无效。

这就是我所做的:

/models/fields/categories.php

foreach ($result as $item) {
    $options[] = JHtml::_('select.option', $item->id, $item->title);
};
$drawField  = '';
$drawField .= '<select name="'.$this->name.'" id="'.$this->name.'" class="inputbox" size="10" multiple="multiple">';
$drawField .= JHtml::_('select.options', $options, 'value', 'text', $strVal, true);
$drawField .= '</select>';
return $drawField;

/models/forms/edit.xml

<field name="catid" type="categories" multiple="true" size="40" class="inputbox" label="COM_PRODUCTS_FORM_LBL_EDIT_CATID" description="COM_PRODUCTS_FORM_DESC_EDIT_CATID" required="true" filter="safehtml" />

/models/edit.php

protected function loadFormData()
{
    $data = JFactory::getApplication()->getUserState('com_products.edit.edit.data', array());
    if (empty($data)) {
        $data = $this->getItem();
        $data->catid = explode(',',$data->catid);
    }
return $data;
}

/tables/edit.php

public function check() {
    if (property_exists($this, 'ordering') && $this->id == 0) {
        $this->ordering = self::getNextOrder();
    }
    $this->catid = implode(',',$this->catid);   
return parent::check();
}

它将字段catid保存为后端的“Array”。然而,当我手动输入143,148作为字段值时,它并没有突出显示那些字段,所以显然我的内爆/爆炸不起作用..任何帮助都将不胜感激!!

谢谢:)

1 个答案:

答案 0 :(得分:4)

好的想通了..问题是这样的:xml文件中的filter =“safehtml”如果其他人遇到同样的问题......现在一切都好了:)