4

I made a subform repeatable fieldtype custom field plugin to integrate with the custom field extension in 3.7x, and it works correctly to display the the fields during article submission. However, the data is not saved.

The extend code

JLoader::import('components.com_fields.libraries.fieldsplugin',JPATH_ADMINISTRATOR);

class PlgFieldsCustomrepeat extends FieldsPlugin {

public function onCustomFieldsPrepareDom($field, DOMElement $parent, JForm $form) {

    $fieldNode = parent::onCustomFieldsPrepareDom($field, $parent, $form);

    if (!$fieldNode) {
        return $fieldNode;
    }

    $fieldNode->setAttribute('type', 'subform');
    $fieldNode->setAttribute('formsource', $field->fieldparams->get('formsource', 0));
    $fieldNode->setAttribute('layout', $field->fieldparams->get('layoutformat'));
    $fieldNode->setAttribute('multiple', true);
    $fieldNode->setAttribute('groupByFieldset', $field->fieldparams->get('fieldsetgroup', 0) ? 'true' : 'false');
    $fieldNode->setAttribute('min', $field->fieldparams->get('min', 0));
    $fieldNode->setAttribute('max', $field->fieldparams->get('max', 1000));
    $fieldNode->setAttribute('default', $field->fieldparams->get('defaultset', 0));

    return $fieldNode;

}


}

I tried a text fieldtype and that sent the data correctly. What needs to be added to allow subform type to work with custom fields? screen shot of subform custom field in article submission view

  • I would LOVE to have repeatable custom fields. AND I would love to have grouped repeatable custom fields which should also be possible. If you get this answered please oh please submit it to the core. – Eoin Dec 6 '17 at 0:12
1

I have a subform field type that's working with all of the subform options - pending a pull request I have in Joomla on GitHub. This is a pretty complex question and has to do with the way Joomla stores custom field data. Joomla will accept a single dimensional array - but subforms are multidimensional arrays.

When/if the PR gets merged, I'll be publishing my subform plugin in the JED.

If the PR doesn't get merged (I'm the 3rd person to try to solve this problem), then the core developers will have blocked yet another attempt to solve this problem.

I'm confident that my approach will be accepted - because it's fully backwards compatible.

Even if they don't - I have another solution.... We'll know by the time 3.9 gets released.

Update: My pull request has made it through the testing process and is now labeled "RTC" (Ready to Commit). Once approved and merged, it will be part of the next Joomla release (probably 3.9).

Update 2: The pull request was merged - my fix will be included in Joomla 3.8.4. When it's released, I'll release my subform plugin on the JED.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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