Skip to main content
edited body; edited title
Source Link
FFrewin
  • 19.8k
  • 10
  • 48
  • 101

creating Creating custom field type multiselect list - how to save the values?

iI 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 iI try to create a custom field type. 

I created my "custom select list " thelist" -the values from the list doesnt getaren't saved somewhere, so iI cant obtain it ackback.

I only edited the getInput function, should iI somehow edit the getOptions() also ??

creating custom field type multiselect list how to save the values

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 " the values from the list doesnt get saved somewhere so i cant obtain it ack.

I only edited the getInput function, should i somehow edit the getOptions() also ??

Creating custom field type multiselect list - how to save the values?

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" -the values from the list aren't saved somewhere, so I cant obtain it back.

I only edited the getInput function, should I somehow edit the getOptions() also ??

deleted 196 characters in body; edited title
Source Link
IseNgaRt
  • 689
  • 6
  • 16

creating custom field type multiselect list how to save the values

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.

creating custom field type multiselect list

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 value from the list doesnt get saved somewhere so i cant obtain it back.

<?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>';
    
    $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.

creating custom field type multiselect list how to save the values

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 " the values from the list doesnt get saved somewhere so i cant obtain it ack.

<?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 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 ??

added 186 characters in body
Source Link
IseNgaRt
  • 689
  • 6
  • 16

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 value from the list doesnt get saved somewhere so i cant obtain it back.

$fmanuf = $params->get('foreignmanuf');

var_dump($fmanuf); ---> returns NULL

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.

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 value from the list doesnt get saved somewhere so i cant obtain it back.

$fmanuf = $params->get('foreignmanuf');

var_dump($fmanuf); ---> returns NULL

Source Link
IseNgaRt
  • 689
  • 6
  • 16
Loading