News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

How remove the "available to all" placeholder in select box of vmcustomfield?

Started by gba, February 10, 2021, 11:41:23 AM

Previous topic - Next topic

gba

Hello!

I created a vmcustomfield having a multiple select box in the product backend.
In function plgVmOnProductEdit() I use:
$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

Hi again!

Following insight I got:
In /administrator/components/com_virtuemart/helpers/vmjsapi.php:521 there is ...$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

Now I found the solution:$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 ...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.  :)