Hello, we are using joomla to configure 2 remote systems and we render select dropdowns with options's values provided by external systems (exact.com).
It seems that choicesjs trims the value of the option and thus when you save the (j)form the values are not same as provided by external system and configuration is lost.
Example how to reproduce:
<joomla-field-fancy-select>
<select name="mytest">
<option value="">Please select a value</option>
<option value="4 ">ID4</option>
</select>
</joomla-field-fancy-select>
Choices change option's value to value="4" and thus when the page renders the "4 " is not selected per stored value. I believe this is very incorrect to change rendered option's values.
We load it via code below, but it's possibly irrelevant:
$doc = JFactory::getDocument();
JHtml::_('jquery.framework');
if (method_exists($doc, 'getWebAssetManager')) {
$doc->getWebAssetManager()
->usePreset('choicesjs')
->useScript('webcomponent.field-fancy-select');
}
best regards, stan
| Labels |
Removed:
?
|
||
| Labels |
Added:
No Code Attached Yet
|
||
Have you verified if the same trim happens upstream with choicesjs or is it specific to the Joomla implementation. If it happens upstream then I dont think there is anything we can do here and you should raise an issue directly with choicesjs
Hi, thanks for reporting this.
From the example provided it appears that ChoicesJS trims the value of the
<option>element (e.g.value="4 "becomingvalue="4"), which would indeed cause issues when the stored value contains trailing spaces.I’ll try to reproduce this behavior with
joomla-field-fancy-selectand check how the value is handled when ChoicesJS initializes the select field. If confirmed, we may need to ensure that option values are preserved exactly as provided rather than being trimmed.I’ll report back once I’ve tested it locally.