News:

Looking for documentation? Take a look on our wiki

Main Menu

selectlist function

Started by AnthonyWang, February 28, 2016, 09:37:18 AM

Previous topic - Next topic

AnthonyWang

Could anyone can give me a customfield multiple select example in plugin?
I tried many solution on it 6days,until now still can't get it work,
please help


$label_options = array('0'=>'Label1','1'=>'Label2');
$html .= VmHTML::row('selectList',
'VMCUSTOM_INFO_LABEL',
'customfield_params['.$row.'][custom_label[]]',
array_values($label_options),
$label_options, //  $custom_label,?
'10',
'multiple="multiple"');

Currently using :
Joomla 3.6.5 / Virtuemart 3.2.1 / PHP 5.5.9-1ubuntu4.17

Studio 42

YOu can use you standard html and Joomla select list, if vmHtml row do not work.
here  is the function with parameters VmHTML::row('selectList','LABEL',$name, $values, $defaultValues, $size, $multiple)

AnthonyWang

#2
Studio,awesome,
but still a problem when i tried this code,
in productedit page,i can't save select option what i select
is this "$label_options" issue?
when i check db, the parameters is empty custom_label=""|



$label_options = array('a'=>'Label1','b'=>'Label2',xxxxxxxxxxxxxxxxxxxxxxxxxxxxx);
$html .= VmHTML::row('selectList','LABEL','customfield_params['.$row.'][custom_label]', $label_options,  $label_options, '10', 'multiple="multiple"',[color=red]false[/color]);

PS: if use multiple select seem shouldn't have a default value?

Currently using :
Joomla 3.6.5 / Virtuemart 3.2.1 / PHP 5.5.9-1ubuntu4.17

PRO

Quote from: AnthonyWang on March 01, 2016, 14:31:28 PM
Studio,awesome,
but still a problem when i tried this code,
in productedit page,i can't save select option what i select
is this "$label_options" issue?
when i check db, the parameters is empty custom_label=""|



$label_options = array('a'=>'Label1','b'=>'Label2',xxxxxxxxxxxxxxxxxxxxxxxxxxxxx);
$html .= VmHTML::row('selectList','LABEL','customfield_params['.$row.'][custom_label]', $label_options,  $label_options, '10', 'multiple="multiple"',[color=red]false[/color]);

PS: if use multiple select seem shouldn't have a default value?



does anything save?

do you have it in varstopush?


for example
      $varsToPush = array(
         'modifier'=>array('','string'),
         'label'=>array('','string'),
         'disc'=>array('','string'),
         'discmod'=>array('','string'),
         'under_disc'=>array('','string'),
         'under_discmod'=>array('','string'),
         'qdisc1'=>array('','string'),
         'qdisc2'=>array('','string'),
         'qdisc3'=>array('','string')
      );

      $this->setConfigParameterable('customfield_params',$varsToPush);

   }

at the top of your plugin file?

AnthonyWang

#4
Hello PRO,
Yes,i had,in first time i create plugin,
$varsToPush = array(
'custom_limit'=>array('', 'int'),
'custom_label'=>array('','string')
);

$this->setConfigParameterable('customfield_params',$varsToPush);

Currently using :
Joomla 3.6.5 / Virtuemart 3.2.1 / PHP 5.5.9-1ubuntu4.17

PRO

what version are you using?

and it can be an xml issue.


AnthonyWang

Hello PRO,
i'm using
Joomla 3.4.8 / Virtuemart 3.0.12 / Php 5.4
Currently using :
Joomla 3.6.5 / Virtuemart 3.2.1 / PHP 5.5.9-1ubuntu4.17

PRO

can you get anything to save?

that happened to me before(nothing saved), and I had to re-do the xml file.


AnthonyWang

#8
Hello PRO,
nothing saved,but i found a possible problem ten min. ago,and found a solution,
it's xml issue, i'll try it tomorrow,If that solution is the right way,i'll report it here.
thanks!

Best Regards.,
Currently using :
Joomla 3.6.5 / Virtuemart 3.2.1 / PHP 5.5.9-1ubuntu4.17

Studio 42

Hi,
And i think the problem is your fieldname
$fieldname = 'customfield_params['.$row.'][custom_label][]';

ELSE NATIVE JOOMLA AND HTML
<tr>
<td><?php echo vmText::_(''VMCUSTOM_INFO_LABEL''?></td>
<td><?php echo JHTML::_('select.genericlist',$options,$fieldname,'multiple="multiple"','value','text',$default?></td>
</tr>

AnthonyWang

Hello Studio,
Awesome! you save my time!it's seems store data in db now,really appreciate!
but there is a issue,in productedit page,the select box is empty,could you tell me,where i can fix it?

Currently using :
Joomla 3.6.5 / Virtuemart 3.2.1 / PHP 5.5.9-1ubuntu4.17

Studio 42

If you use Joomla list, you need to conform to generic list options.
Eg.
<?php 
$fieldname 
'customfield_params['.$row.'][custom_label][]';
$options = array();
foreach(
$label_options as $key=>$value) {
$options[] = JHTML::_('select.option'$key$value);
}
$html .='<tr>
<td>'
vmText::_(''VMCUSTOM_INFO_LABEL'').'</td>
<td>'
JHTML::_('select.genericlist',$options,$fieldname,'multiple="multiple"','value','text',$default) .'</td>
</tr>'
;


AnthonyWang

Thanks Studio,i'll try it later
Currently using :
Joomla 3.6.5 / Virtuemart 3.2.1 / PHP 5.5.9-1ubuntu4.17