In my Joomla 3 component, i have a custom field that is a select list with multiple=true.
The values of such an select list are binary handled like 1,2,4,8,16.
When storing, the values are getting added and stored as one value. When displaying the select field, the binary values are getting reassembled into an array.
All works in Joomla 3, but an Joomla 4 Select list with fancy layout or not is not displaying the selected values. The storage of the binary value works, but not the display.
I saw that list field source has changed in J4, but haven't found the issue for this.
<?php
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\Form\Field\ListField;
class JFormFieldBinaryselect extends ListField
{
public $type = 'Binaryselect';
protected static $options = array();
protected function getOptions()
{
if ($this->value > 0) {
// creates array from value like: 12 = [4,8]
$this->value = MyHelper::getBinArray($this->value);
}
return parent::getOptions();
}
}