http://docs.joomla.org/Adding_a_multiple_item_select_list_parameter_type
Thats the documentation for the way to add a custom parameter type to your module and if you look at the bottom round there is this line : Saving parameter values to a database
Please can someone tell me if there is any documentation on how to do this in Joomla 1.6 because I cannot find it anywhere?
I understand completely how this works though, You need to bind your custom options (example: the list selection from a multiple selection input box) to the parent so that it will be able to save the selection to the DB.
Thank you in advance.
EDIT added code
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']
);
}
Checkout this, How to convert JParams to JForm
EDIT :
I checked the forum and found that you are using
// Builds the options for the dropdown
foreach ( $response['data'] as $list )
{
$lists[$list['list_id']] = $list['list_name'];
}
but in JHTML you are passing id and title for text and value field,
Use
// 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'];
}
精彩评论