I try to create a FieldsPlugin with a repeatable subform. The display works great but the storage in database does not work.
Here's my plugin structure :
plugins/fields/slides/slides.xml
plugins/fields/slides/subform.xml (contains the subform to repeat)
plugins/fields/slides/tmpl/slides.php (just a hello world for the moment)
plugins/fields/slides/params/slides.xml (standard field plugin params)
The plugin is installed and works, I can choose the type "slides" when I create a custom field.
My repeatable subform shows well on the content form page.
When I save my form there are same amount of lines added in #__fields_values as the amount of lines of repeatable subform I created the field_id and item_id are correct but the value column is empty.
I suppose that the framework doesn't test the type of "value" before sending it the database. So it send the Array() (PHP) and that cause a blank value in the database.
Anybody here already tries to make something similar ? Any advice ?
Thanks for help.
My code :
plugins/fields/slides/tmpl/slides.php
Code: Select all
<?php
defined('_JEXEC') or die;
JLoader::import('components.com_fields.libraries.fieldsplugin', JPATH_ADMINISTRATOR);
class PlgFieldsSlides 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', "plugins/fields/slides/subform.xml");
$fieldNode->setAttribute('multiple', 'true');
$fieldNode->setAttribute('layout', 'joomla.form.field.subform.repeatable-table');
return $fieldNode;
}
}
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fieldset name="section1" label="Section1">
<field name="title" type="text" label="Title" required="true"/>
<field name="slide" type="media" label="Image" required="true"/>
</fieldset>
</form>