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"');
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)
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?
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?
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);
what version are you using?
and it can be an xml issue.
Hello PRO,
i'm using
Joomla 3.4.8 / Virtuemart 3.0.12 / Php 5.4
can you get anything to save?
that happened to me before(nothing saved), and I had to re-do the xml file.
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.,
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>
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?
(http://imgur.com/nvMPg6z)
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>';
Thanks Studio,i'll try it later