News:

Looking for documentation? Take a look on our wiki

Main Menu

Create customfield with type Boolean as radio button

Started by Mole_LR, February 17, 2016, 18:49:11 PM

Previous topic - Next topic

Mole_LR

Hi!

Joomla: 3.4.8.
Virtuemart: 3.0.13.4
Joomla admin template : isis

There is customfield with type Boolean, in VM2+J2 it works fine in back-end (as needed) - these customfield with type boolean appears as radio buttons: Yes/No, but in VM3 - input field...

Steps I'm doing:
1)Create customfield as type Boolean;
2)Cart attribute, Cart input = No (I do not need anything to choose on front-end, just specify properties for product;
3)Admin only = Yes;
4)Is A List = No;
5)After saving there appears Additional parameters, choose there "as radiolist" = Yes!
See image (Customfield-settings.png)!

When create product and choose this customfield, there just blank field appears (see image Boolean.png)!

When choose customfield with type Boolean to Is A List = Yes, then there is need to fill Default values (let's say: Yes; No), then for product creation this customfield appears as Listbox with Yes/No, and it is not what is needed!

Am I missing smth/setting not correctly or this is "feature" how it works in VM3? Did not find appropriate answer in forum, therefore asking!

Thank You! ;-)

edited:
It is necessary to add for example car equipment with Yes/No, radio button is 1 click, Listbox - 2 clicks... Such issue was when upgrading VM2 to VM3 (in VM2 there were radiobuttons as boolean, VM3 - select list with yes/no as select options)...

Mole_LR

Hi!

Solved this issue! VM3 by default uses SelectList for String customfields if selected as List (Boolean customfield Type was not OK for me in this case, because I was need that customfield is registered for product always with Yes/No (or more options) instead of registered just when selected)... Additionally I set radioList labels to show as translated fields (because I was need to translate these customfield values in 3 languages in FE, but by default in BE it shows translated strings instead of translations)! Also used some nice plugin for displaying radioList...

So, was need change VM core files:
1.)change /administrator/components/com_virtuemart/models/customfields.php:
5.1.)line 622 from
   $options[] = array('value' => $val, 'text' => $val);
to
   $options[] = JHtml::_('select.option',  $val, vmText::_($val));
5.2.)line 626 from
   return $priceInput . '</td><td>'.JHtml::_ ('select.genericlist', $options, 'field[' . $row . '][customfield_value]', NULL, 'value', 'text', $currentValue);
to
   return $priceInput . '</td><td>'.JHtml::_ ('select.genericlist', $options, 'field[' . $row . '][customfield_value]', 'style="display:none"', 'value', 'text', $currentValue) .
   '<br /><fieldset class="checkboxes">'.JHtml::_('select.radiolist', $options, 'field[' . $row . '][customfield_value]', 'class="icheck-plugin"', 'value', 'text', $currentValue).'</fieldset>';

Hope anybody will need similar workaround! ;-)