?
avatar emmanuel-tsalampounis
emmanuel-tsalampounis
14 Apr 2021

Steps to reproduce the issue

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"
/>

Expected result

When I select multiple values to be displayed as selected

Actual result

The values are stored in db but aren't selected

System information (as much as possible)

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

Additional comments

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?

avatar emmanuel-tsalampounis emmanuel-tsalampounis - open - 14 Apr 2021
avatar joomla-cms-bot joomla-cms-bot - change - 14 Apr 2021
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 14 Apr 2021
avatar emmanuel-tsalampounis emmanuel-tsalampounis - change - 14 Apr 2021
The description was changed
avatar emmanuel-tsalampounis emmanuel-tsalampounis - edited - 14 Apr 2021
avatar ReLater
ReLater - comment - 14 Apr 2021

can't be used on all field types?

Related issue concerning the question: #31249

avatar sandramay0905
sandramay0905 - comment - 17 Apr 2021

@emmanuel-tsalampounis please add "[4.0] " to the title to make it easy to know, which version is meant.

avatar emmanuel-tsalampounis emmanuel-tsalampounis - change - 19 Apr 2021
Title
Problem of list-fancy-select layout on sql field type
[4.0] Problem of list-fancy-select layout on sql field type
avatar emmanuel-tsalampounis emmanuel-tsalampounis - edited - 19 Apr 2021
avatar Fedik
Fedik - comment - 19 Apr 2021

@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"
/>
avatar emmanuel-tsalampounis
emmanuel-tsalampounis - comment - 20 Apr 2021

@Fedik No it has the same bug. When I select one value only it works but when I select more, after saving none is selected

avatar Fedik
Fedik - comment - 20 Apr 2021

Okay. In which place do you use the field, and how do you save it in a database?

avatar emmanuel-tsalampounis
emmanuel-tsalampounis - comment - 20 Apr 2021

@Fedik I use the field in a back-end form of a custom component. The values are saved as a comma separated string in a MySQL field of type text. Does it need another format to work?

avatar Fedik
Fedik - comment - 20 Apr 2021

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.

avatar emmanuel-tsalampounis emmanuel-tsalampounis - change - 23 Apr 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-04-23 09:42:41
Closed_By emmanuel-tsalampounis
avatar emmanuel-tsalampounis emmanuel-tsalampounis - close - 23 Apr 2021
avatar emmanuel-tsalampounis
emmanuel-tsalampounis - comment - 23 Apr 2021

@Fedik you are right, format was wrong in my model. Thank you

Add a Comment

Login with GitHub to post a comment