Self-Replicating Form Fields

February 9th, 2012

Self-Replicating Form FieldsThere are times as a Joomla developer when it would be very useful to have a form field in Joomla that is capable of self-replication. For example, you want your user to be able to input some links, but you don’t know in advance how many there will be, you want your user to be able to choose to add as many as they want without imposing any arbitrary limit. What you want is a self-replication form field that can return its values as an array.

This tool for Joomla developers is designed to generate self-replicating form fields for use in Joomla extensions. It is compatible with Joomla 1.5 and 1.6/1.7/2.5, with mootols 1.1 and 1.2 and 1.3, and does not require any other javascript library, so no conflicts with the Joomla admininstrator template. It is very lightweight, consisting of a single javascript file, plus the the Joomla element and formfield classes necessary to generate the custom parameter. It can be used in component, module or plugin parameters to generate an array of self-replicating form fields. Instead of returning a single value as a standard Joomla parameter does, it returns an array of values.

The variable field form field can be used to generate self-replicating fields of most of the Joomla standard field types, including text, textarea, list and other list based types, such as category or usergroup. The user will see the standard input field, plus buttons which allow the user to add or delete input fields, also to re-order them, also to re-order them up and down.

Please note that this is a tool for Joomla developers, it is not an extension that you can upload and install in Joomla. However the download package does include an example content plugin that demonstrates how to use the field.