i want to make a module that parses the manufacturers from virtuemart , and the user will select which manufacturers he wants to be shown in the index page. Its the first time i try to create a custom field type. I created my "custom select list " altough i can select only 1 option at the moment and i would like to make it a multi selecet one.
Also it seems that the valuevalues from the list doesnt get saved somewhere so i cant obtain it backack.
<?php
defined('JPATH_PLATFORM') or die;
class JFormFieldManulist extends JFormField
{
protected $type = 'Manulist';
protected function getInput()
{
$db= JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('*');
$query->from('#__virtuemart_manufacturers_en_gb');
$db->setQuery($query);
$options = $db->loadObjectList();
$longstring= '<select>';'<select multiple="multiple">';
$counter=1;
foreach( $options as $row ) {
$longstring .= '<option value="' . $counter . '">'. $row->mf_name . ' </option>' ;
$counter++;
}
$longstring.= '</select>';
return $longstring;
}
protected function getOptions()
{
$options = array();
foreach ($this->element->children() as $option)
{
if ($option->getName() != 'option')
{
continue;
}
$tmp = JHtml::_(
'select.option', (string) $option['value'],
JText::alt(trim((string) $option), preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)), 'value', 'text',
((string) $option['disabled'] == 'true')
);
$tmp->class = (string) $option['class'];
$tmp->onclick = (string) $option['onclick'];
$options[] = $tmp;
}
reset($options);
return $options;
}
}
I only edited the getInput function, should i somehow edit the getOptions() also ??
I tried to make it as $longstring= ''; but no result also.
Thanks for your time.