Skip to content

Add possibility to save multiple values as JSON#19782

Closed
fastslack wants to merge 1 commit intojoomla:3.10-devfrom
fastslack:jform-multiple-list
Closed

Add possibility to save multiple values as JSON#19782
fastslack wants to merge 1 commit intojoomla:3.10-devfrom
fastslack:jform-multiple-list

Conversation

@fastslack
Copy link
Copy Markdown
Contributor

Summary of Changes

This change add the possibility to save multiple values of FieldList as JSON.

Testing Instructions

Create using JForm a list with multiple value enabled like:

    <field multiple="true" name="options" type="list" label="COM_TEST_FORM_LBL_OPTIONS" description="COM_TEST_FORM_DESC_OPTIONS" hint="COM_TEST_FORM_LBL_OPTIONS">
      <option value="0">COM_TEST_PRODUCTS_OPTIONS_0</option>
      <option value="1">COM_TEST_PRODUCTS_OPTIONS_1</option>
      <option value="2">COM_TEST_PRODUCTS_OPTIONS_2</option>
    </field>

Then add into save() function in models:

    $data['options'] = json_encode($data['options']);

Expected result

You can save multiple values as JSON into database

@laoneo
Copy link
Copy Markdown
Member

laoneo commented Mar 23, 2022

Sorry that it took so long to respond. While this is a nice addition for Joomla, it should be added to version 4 as it is a new feature. Can you rebase it to the 4.2-dev branch? In the meantime I'm closing the pr, when ready please reopen so we can properly test it. Thanks for your contribution, making Joomla better.

@laoneo laoneo closed this Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants