Actions

Difference between revisions of "Repeatable form field type"

From Joomla! Documentation

(Save progress on repeatable form fields)
 
(Marked this version for translation)
 
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Provides a modal with rows of formfields that you specify. As many options can be added as desired. Note this form field has a jQuery based javascript file as a dependency.
+
<noinclude><languages /></noinclude>
 +
<translate><!--T:1-->
 +
Provides a modal with rows of formfields that you specify. As many options can be added as desired. Note this form field has a jQuery based javascript file as a dependency.</translate>
  
* '''name''' (mandatory) is the unique name of the parameter.
+
<translate><!--T:2-->
* '''type''' (mandatory) must be ''repeatable''.
+
* '''name''' (mandatory) is the unique name of the parameter.</translate>
* '''label''' (mandatory) (translatable) is the descriptive title of the field.
+
<translate><!--T:3-->
* '''description''' description text for the form field. Displays at the top of the modal with the name as well as in the usual position in the form
+
* '''type''' (mandatory) must be ''repeatable''.</translate>
* '''default''' The default value for the form field if the field is left empty.
+
<translate><!--T:4-->
* '''id''' id of the hidden from field. (the modal will have this id with an added suffix of "_modal" and the table within the modal will have this id with a suffix of _modal_table")
+
* '''label''' (mandatory) (translatable) is the descriptive title of the field.</translate>
* '''class''' class of the table.
+
<translate><!--T:5-->
* '''select''' (translatable) The text to show on the modal button.
+
* '''description''' description text for the form field. Displays at the top of the modal with the name as well as in the usual position in the form.</translate>
* '''icon''' the icon to show on the select button (is prefixed with "icon-").
+
<translate><!--T:6-->
* '''maximum''' the maximum number of rows of fields allowed (by default 999 to be effectively infinite)
+
* '''default''' The default value for the form field if the field is left empty. Note this has to be a json string compatible with the contents of the form field.</translate>
 +
<translate><!--T:7-->
 +
* '''id''' id of the hidden from field. (the modal will have this id with an added suffix of "_modal" and the table within the modal will have this id with a suffix of _modal_table").</translate>
 +
<translate><!--T:8-->
 +
* '''class''' class of the table.</translate>
 +
<translate><!--T:9-->
 +
* '''select''' (translatable) The text to show on the modal button.</translate>
 +
<translate><!--T:10-->
 +
* '''icon''' the icon to show on the select button (is prefixed with "icon-").</translate>
 +
<translate><!--T:11-->
 +
* '''maximum''' the maximum number of rows of fields allowed (by default 999 to be effectively infinite).</translate>
  
Example XML Definition
+
<translate><!--T:18-->
 +
To create a form field you must first of all create a repeatable form field as usual.</translate>
 +
<source lang="php">
 +
<fields></source>
 +
<translate><!--T:19-->
 +
Within this you place open and close tag (if not already in one - if there is an existing fields tag for params etc. this is not needed.) and within this a tag.</translate>
 +
<source lang="php">
 +
<fieldset></source>
 +
<translate><!--T:20-->
 +
The fieldset tag MUST have a name the same as your repeatable field name with "_modal" appended to the end of it - it should also have the in the fieldset tag.</translate>
 +
<source lang="php">
 +
repeat="true"</source>
 +
<translate><!--T:21-->
 +
Within this fieldset you then include the form fields that you wish to have repeating (as with any form field).</translate>
 +
 
 +
<translate><!--T:16-->
 +
Example XML Definition</translate>
 
<source type="xml">
 
<source type="xml">
<field name="list_templates"
+
<field name="list_templates"
type="Repeatable"
+
type="Repeatable"
icon="list"
+
icon="list"
description="PLG_TINY_FIELD_TEMPLATE_FIELD_ELEMENTS_DESC"
+
description="PLG_TINY_FIELD_TEMPLATE_FIELD_ELEMENTS_DESC"
label="PLG_TINY_FIELD_TEMPLATE_FIELD_ELEMENTS_LABEL"
+
label="PLG_TINY_FIELD_TEMPLATE_FIELD_ELEMENTS_LABEL"
default="{'template':['Layout','Simple snippet'],'location':['layout1.html','snippet1.html'],'description':['HTMLLayout','Simple HTML snippet']}">
+
default="{'template':['Layout','Simple snippet'],'location':['layout1.html','snippet1.html'],'description':['HTMLLayout','Simple HTML snippet']}">
<fields name="params">
+
<fieldset hidden="true" name="list_templates_modal" repeat="true">
<fieldset hidden="true" name="list_templates_modal" repeat="true">
+
<field name="template"
<field name="template"
+
label="PLG_TINY_FIELD_TEMPLATE_FIELD_NAME_LABEL"
label="PLG_TINY_FIELD_TEMPLATE_FIELD_NAME_LABEL"
+
size="30"
size="30"
+
type="text" />
type="text"/>
+
<field name="location"
<field name="location"
+
label="PLG_TINY_FIELD_TEMPLATE_FIELD_LOCATION_LABEL"
label="PLG_TINY_FIELD_TEMPLATE_FIELD_LOCATION_LABEL"
+
description="PLG_TINY_FIELD_TEMPLATE_LOCATION_DESC"
description="PLG_TINY_FIELD_TEMPLATE_LOCATION_DESC"
+
size="30"
size="30"
+
type="filelist"
type="filelist"
+
directory="media/editors/tinymce/templates"
directory="media/editors/tinymce/templates"
+
exclude="index.html"
exclude="index.html"
+
hide_default="true"
hide_default="true"
+
hide_none="true" />
hide_none="true"/>
+
<field name="description"
<field name="description"
+
label="PLG_TINY_FIELD_TEMPLATE_FIELD_DESCRIPTION_LABEL"
label="PLG_TINY_FIELD_TEMPLATE_FIELD_DESCRIPTION_LABEL"
+
size="30"
size="30"
+
type="textarea" />
type="textarea"
+
</fieldset>
/>
+
</fieldset>
+
</fields>
+
 
</field>
 
</field>
 
</source>
 
</source>
  
 +
<noinclude>
 +
<translate>
 +
<!--T:17-->
 
[[Category:Standard form field types]]
 
[[Category:Standard form field types]]
 +
</translate>
 +
</noinclude>

Latest revision as of 08:38, 30 July 2015

Other languages:
English • ‎français

Provides a modal with rows of formfields that you specify. As many options can be added as desired. Note this form field has a jQuery based javascript file as a dependency.

  • name (mandatory) is the unique name of the parameter.
  • type (mandatory) must be repeatable.
  • label (mandatory) (translatable) is the descriptive title of the field.
  • description description text for the form field. Displays at the top of the modal with the name as well as in the usual position in the form.
  • default The default value for the form field if the field is left empty. Note this has to be a json string compatible with the contents of the form field.
  • id id of the hidden from field. (the modal will have this id with an added suffix of "_modal" and the table within the modal will have this id with a suffix of _modal_table").
  • class class of the table.
  • select (translatable) The text to show on the modal button.
  • icon the icon to show on the select button (is prefixed with "icon-").
  • maximum the maximum number of rows of fields allowed (by default 999 to be effectively infinite).

To create a form field you must first of all create a repeatable form field as usual.

<fields>

Within this you place open and close tag (if not already in one - if there is an existing fields tag for params etc. this is not needed.) and within this a tag.

<fieldset>

The fieldset tag MUST have a name the same as your repeatable field name with "_modal" appended to the end of it - it should also have the in the fieldset tag.

repeat="true"

Within this fieldset you then include the form fields that you wish to have repeating (as with any form field).

Example XML Definition

<field name="list_templates"
	type="Repeatable"
	icon="list"
	description="PLG_TINY_FIELD_TEMPLATE_FIELD_ELEMENTS_DESC"
	label="PLG_TINY_FIELD_TEMPLATE_FIELD_ELEMENTS_LABEL"
	default="{'template':['Layout','Simple snippet'],'location':['layout1.html','snippet1.html'],'description':['HTMLLayout','Simple HTML snippet']}">
	<fieldset hidden="true" name="list_templates_modal" repeat="true">
		<field name="template"
			label="PLG_TINY_FIELD_TEMPLATE_FIELD_NAME_LABEL"
			size="30"
			type="text" />
		<field name="location"
			label="PLG_TINY_FIELD_TEMPLATE_FIELD_LOCATION_LABEL"
			description="PLG_TINY_FIELD_TEMPLATE_LOCATION_DESC"
			size="30"
			type="filelist"
			directory="media/editors/tinymce/templates"
			exclude="index.html"
			hide_default="true"
			hide_none="true" />
		<field name="description"
			label="PLG_TINY_FIELD_TEMPLATE_FIELD_DESCRIPTION_LABEL"
			size="30"
			type="textarea" />
	</fieldset>
</field>