Joomla text Form Field Type

The text form field type provides a text box for data entry. If the field has a value saved, this value is displayed when the page is first loaded. If not, the default value (if any) is selected.

XML Field Definition

<field
name="mytextvalue"
type="text"
default="Some text"
label="Enter some text"
description=""
size="10" />

Use the integer filter to ensure that letters get stripped when the form is processed.

<field 
name="myintvalue"
type="text"
default=""
label="Enter some text"
description="Enter some description"
filter="integer" />

Use the raw filter to ensure that html code is preserved when the form is processed.

<field 
name="myhtmlvalue"
type="text"
default=""
label="Enter some text"
description="Enter some description"
filter="raw" />

Mandatory Parameters

  1. type must be text.
  2. name is the unique name of the field.
  3. label (translatable) is the descriptive title of the field.

Optional Parameters

  1. size is the width of the text box in characters.
  2. maxlength limits the number of characters that may be entered.
  3. default (not translatable) is the default value.
  4. description (translatable) is help text for the field.
  5. class - CSS class name for the HTML form field.
  6. readonly - The field cannot be changed and will automatically inherit the default value.
  7. disabled - The field cannot be changed and will automatically inherit the default value. It will also not submit.
  8. required - The field must be filled before submitting the form.
  9. filter - Allow the system to save certain html tags or raw data.
  10. message - The error message that will be displayed instead of the default message.
  11. hint - The text displayed in the html placeholder element, usually a lighter coloured hint displayed inside an blank field.
  12. pattern - A regular expression pattern to use for validation.

Examples

1. Title Field (com_content)

<field
name="title"
type="text"
label="JGLOBAL_TITLE"
required="true"
maxlength="255" />

2, Alias Field (com_content)

<field
name="alias"
type="text"
label="JFIELD_ALIAS_LABEL"
description="JFIELD_ALIAS_DESC"
hint="JFIELD_ALIAS_PLACEHOLDER" />

3. Ordering Field (com_content)

<field
name="ordering"
type="text"
label="JFIELD_ORDERING_LABEL"
default="0" />

4. Site Name Field (Global Configuration)

<field
name="sitename"
type="text"
label="COM_CONFIG_FIELD_SITE_NAME_LABEL"
required="true"
filter="string" />