I'm in the process of developing a system plugin. In the options is a subform-field (repetable), which contains several fields. In the "default" of the subform I can specify a record.

a) How can I add multiple records as example records?

b) For a "number" field the 0 should be given as default value. But unfortunately this is not taken over.

c) Is it possible to add an install script to the plugin, similar to a component, to install example data?

A data set in the subform-field:

default='[{"flexible_holidays_name": "Easter Sunday", "flexible_holidays_days": "0"}]'

My attempt with several data sets:

default='[{"flexible_holidays0":{"flexible_holidays_name": "Good Friday", "flexible_holidays_days":"-2"}, "flexible_holidays1":{"flexible_holidays_name": "Easter Sunday", "flexible_holidays_days": "0"}}]'

3 Answers 3


I am not sure there is not a simpler way. But this way you'll get what you want.

a) Create a custom field to implement your logic. You can extend from any basic custom field types.

b) Simply set it manually to default to 0 (the attribute default="0" is accepted in most form types). This will not set the value until the user actually saves the preferences; or you could preset the values in the script mentioned below.

c) Yes. it works for any extension type. Check the docs here.

Please take a moment to check the naming convention: the class name in the installer must be exact, otherwise it will simply not be invoked, and no error will be thrown to set you on the right path. In your install.php methods i.e. install, update, preflight, postflight, you can queue messages:


to know when code is working.

For example

If my extension plugin xml name is "easyhttps":

<filename plugin="easyhttps">easyhttps.php</filename>

becomes PlgSystemJsonloggerInstallerScript in the classname of the installer:

class PlgSystemJsonloggerInstallerScript

A plugin with an underscore in its name: "stripe_button"

<filename plugin="stripe_button">stripe_button.php</filename>

Will keep it in the classname of the installer: PlgSystemStripe_buttonInstallerScript

class PlgSystemStripe_buttonInstallerScript

Bonus: A plugin with an underscore and a dash in its name: "editors-xtd/stripe_xtd"

<extension version="2.5.0" type="plugin" group="editors-xtd" method="upgrade">
<filename plugin="stripe_xtd">stripe_xtd.php</filename>

Will lose the dash in the classname of the installer: Plgeditorsxtdstripe_xtdInstallerScript

class Plgeditorsxtdstripe_xtdInstallerScript


It is not too important: all the following work:

class PlgEditorsxtdstripe_xtdInstallerScript
class PlgEditorsxtdStripe_xtdInstallerScript
class Plgeditorsxtdstripe_xtdInstallerScript

Remove the square brackets so data becomes a JSON object containing objects of each row:

default='{"flexible_holidays0":{"flexible_holidays_name": "Good Friday", "flexible_holidays_days":"-2"}, "flexible_holidays1":{"flexible_holidays_name": "Easter Sunday", "flexible_holidays_days": "0"}}'

Just note that having this as default essentially makes the field required. If users remove all rows, the value stored will default to this.


The square bracket was the problem. The user must specify at least 1 record. Otherwise he can deactivate the plugin.

b) the number-field in the subform must specified the default="0". this i have yesterday found.

c) Maybe I'll change it later to an installation script to install the sample data instead of default value.

Now I will leave it at default value.

Thank you for your help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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