Author Topic: How remove the "available to all" placeholder in select box of vmcustomfield?  (Read 1036 times)

gba

  • Jr. Member
  • **
  • Posts: 326
Hello!

I created a vmcustomfield having a multiple select box in the product backend.
In function plgVmOnProductEdit() I use:
Code: [Select]
$html .= VmHTML::row('select',vmText::_('VMCUSTOM_MYPLG_CHOOSE'),'select['.$row.'][]',array("opt1"=>vmText::_('VMCUSTOM_MYPLG_OPT1'),"opt2"=>vmText::_('VMCUSTOM_MYPLG_OPT2')),explode(',',$field->customfield_value),'multiple="multiple"','value','text',false);When no option is chosen, a "placeholder like" value 'COM_VIRTUEMART_DRDOWN_AVA2ALL' (translated) is visible, which disappears when I click into the field.
In my case this information is wrong.

How can I generate the select box without any descriptive value in it?

Thank you very much in advance for your help!

Kind regards,
Gerald

gba

  • Jr. Member
  • **
  • Posts: 326
Hi again!

Following insight I got:
In /administrator/components/com_virtuemart/helpers/vmjsapi.php:521 there is ...
Code: [Select]
$selectText = 'COM_VIRTUEMART_DRDOWN_AVA2ALL';So, in VM the prefilled value of a chzn select box seems to be hardcoded with "Available for all"!

This approach is very limited:
Depending on the context of a vmcustomfield having a select box to choose options, this statement can be totally wrong and deceptive (like in my case).

Do I, maybe need another function instead of 'select' in my VmHTML call, to prevent VM from misleading the website admin?

Kind regards,
Gerald

gba

  • Jr. Member
  • **
  • Posts: 326
Now I found the solution:
Code: [Select]
$html .= VmHTML::row('select',vmText::_('VMCUSTOM_MYPLG_CHOOSE'),'select['.$row.'][]',array("opt1"=>vmText::_('VMCUSTOM_MYPLG_OPT1'),"opt2"=>vmText::_('VMCUSTOM_MYPLG_OPT2')),explode(',',$field->customfield_value),'multiple="multiple" data-placeholder="'.vmText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION').'"','value','text',false);
The additional ...
Code: [Select]
data-placeholder="'.vmText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION').'"... in the attributes argument prefills the select box with "Please select" (COM_VIRTUEMART_LIST_EMPTY_OPTION) instead.  :)