I am adding list-fancy-select
layout on a sql field as:
<field
name="sqlmultiple"
query="select id,title from #__content"
key_field="id"
value_field="title"
multiple="true"
type="sql"
layout="joomla.form.field.list-fancy-select"
required="true"
label="COM_TENIS_FORM_LBL_ASDF1F_SQLMULTIPLE"
description="COM_TENIS_FORM_DESC_ASDF1F_SQLMULTIPLE"
hint="COM_TENIS_FORM_LBL_ASDF1F_SQLMULTIPLE"
/>
When I select multiple values to be displayed as selected
The values are stored in db but aren't selected
PHP Built On Linux 39f2b7fe885b 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64
Database Type mysql
Database Version 8.0.23
Database Collation utf8mb4_general_ci
Database Connection Collation utf8mb4_0900_ai_ci
Database Connection Encryption None
Database Server Supports Connection Encryption Yes
PHP Version 7.4.16
Web Server Apache/2.4.38 (Debian)
WebServer to PHP Interface apache2handler
Joomla! Version Joomla! 4.0.0-beta7 Beta [ Mañana ] 2-February-2021 19:23 GMT
User Agent Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0
I have debugged the $value
variable that goes to layouts\joomla\form\field\list-fancy-select.php
, It is a string.
Seem that it needs a conversion as I see here libraries\src\Form\Field\TagField.php
:
if (\is_string($this->value))
{
$this->value = explode(',', $this->value);
}
Could it be considered as a bug or list-fancy-select
can't be used on all field types?
Labels |
Added:
?
|
@emmanuel-tsalampounis please add "[4.0] " to the title to make it easy to know, which version is meant.
Title |
|
@emmanuel-tsalampounis does it works for you for a standard <select>
?:
<field
name="sqlmultiple"
query="select id,title from #__content"
key_field="id"
value_field="title"
multiple="true"
type="sql"
required="true"
label="Label"
/>
Okay. In which place do you use the field, and how do you save it in a database?
That the problem, you need to prepare your data when you load it from database.
It not Joomla issue.
If you save value as a comma separated string then you should do reverse thing after load the value from database.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-04-23 09:42:41 |
Closed_By | ⇒ | emmanuel-tsalampounis |
Related issue concerning the question: #31249