3

I'm trying to use the Joomla subform field with multiple="true" on (instead of using the old modal repeatable method).

My problem is that the data is not saving to the database. I have read multiple examples but cannot see what I'm doing wrong.

If I turn off multiple="true" then the subform saves data as a JSON string to the database just fine. When I turn it back on, it won't save no matter what I try.

My issue is basically this one, but there were no solutions and I don't have enough reputation to simply comment on it: Why doesn't my subform field data get saved?

My component XML:

<field name="list_links_url" 
        type="subform"
        label="Subform Field" 
        description="Subform Field Description"
        layout="joomla.form.field.subform.repeatable-table"
        multiple="true"
        formsource="/administrator/components/com_products/model/form/subforms/subform_list_links.xml" 
    />

Subform XML:

<?xml version="1.0" encoding="UTF-8"?>
<form>
        <field name="link"
            label="Link"
            type="text"
            description="Enter a URL" 
        />
</form>

FYI - Brand new install of Joomla 3.6.5 and PHP 7.0.10

Any help would be greatly appreciated.

  • There is nothing wrong with the code you posted above. Can you say where you are using it? Frontend or backend? In config or passing it to a controller task? etc. – jamesgarrett Feb 20 '17 at 7:53
3

In your table's bind function, add this:

if ( ( !empty( $array[ 'list_links_url' ] ) && ( is_array( $array[ 'list_links_url' ] ) ) ) ) {
            $this->_jsonEncode[] = "list_links_url";
        }
  • This is the closest to a solution I've come across, thanks for taking the time. In the end I've chosen to use the old repeatable method but this is still useful, thanks. – sigil Apr 24 '17 at 18:11

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.