1

http://docs.joomla.org/Adding_a_multiple_item_select_list_parameter_type

这就是向您的模块添加自定义参数类型的方式的文档,如果您查看底部圆形,则有这一行:将参数值保存到数据库

请有人告诉我是否有任何关于如何在 Joomla 1.6 中执行此操作的文档,因为我在任何地方都找不到它?

我完全理解这是如何工作的,您需要将您的自定义选项(例如:来自多选输入框的列表选择)绑定到父项,以便它能够将选择保存到数据库。

先感谢您。

编辑添加代码

protected function getInput()
    {

        $options = array();
        $attr = '';

        $attr .= ' multiple="multiple"';
        $attr .= ' style="width:220px;height:160px;"';

        // Get the database instance
        $db = JFactory::getDbo();
        // Build the select query
        $query = 'SELECT params FROM jos_modules'
            . ' WHERE module="mod_pmailer_subscription"';
        $db->setQuery($query);
        $params = $db->loadObjectList();

        // Decode the options to get thje api key and url
        $options = json_decode($params[0]->params, true);

        // Create a new API utility class
        $api = new PMailerSubscriptionApiV1_0(
            $options['enterprise_url'],
            $options['pmailer_api_key']
        );

        // Get the lists needed for subscription
        $response = $api->getLists();

        // Make a default entry for the dropdown
        $lists = array('0' => 'Please select a list');

        // Builds the options for the dropdown
        foreach ( $response['data'] as $list )
        {
            $lists[$list['list_id']]['id']    = $list['list_id'];
            $lists[$list['list_id']]['title'] = $list['list_name'];
        }

        // The dropdown output
        return JHTML::_(
            'select.genericlist',
            $lists,
            'jform[params][list_id]',
            trim($attr),
            'id',
            'title',
            $options['list_id']
        );

    }
4

1 回答 1

3

签出这个,如何将 JParams 转换为 JForm

编辑 :

我查看了论坛,发现您正在使用

// Builds the options for the dropdown
foreach ( $response['data'] as $list )
{
   $lists[$list['list_id']] = $list['list_name'];
}

但是在 JHTML 中,您正在为文本和值字段传递 id 和标题,

采用

    // Builds the options for the dropdown
    foreach ( $response['data'] as $list )
    {
        $lists[$list['list_id']]['id']    = $list['list_id'];
        $lists[$list['list_id']]['title'] = $list['list_name'];
    }
于 2011-05-05T15:08:36.067 回答