FormField

Implements DatabaseAwareInterface

Abstract Form Field class for the Joomla Platform.

abstract
since

1.7.0

package

Joomla CMS

Methods

__construct

Method to instantiate the form field object.

__construct(\Joomla\CMS\Form\Form form = null) : 
since

1.7.0

Arguments

form

FormThe form to attach to the form field object.

Response

mixed

__get

Method to get certain otherwise inaccessible properties from the form field object.

__get( name) : 
since

1.7.0

Arguments

name

stringThe property name for which to get the value.

Response

mixedThe property value or null.

__set

Method to set certain otherwise inaccessible properties of the form field object.

__set( name,  value) : 
since

3.2

Arguments

name

stringThe property name for which to set the value.

value

mixedThe value of the property.

Response

void

filter

Method to filter a field value.

filter( value,  group = null, \Joomla\Registry\Registry input = null) : 
since

4.0.0

throws

UnexpectedValueException

Arguments

value

mixedThe optional value to use as the default for the field.

group

stringThe optional dot-separated form group path on which to find the field.

input

Registry|nullAn optional Registry object with the entire data set to filter against the entire form.

Response

mixedThe filtered value.

getAttribute

Method to get an attribute of the field

getAttribute( name,  default = null) : 
since

3.2

Arguments

name

stringName of the attribute to get

default

mixedOptional value to return if attribute not found

Response

mixedValue of the attribute / default

getDataAttributes

Method to get data attributes. For example, data-user-type

getDataAttributes() : mixed||string|int
since

4.0.0

Response

array<string|int, mixed>list of data attribute(s)

getFieldName

Method to get the field name used.

getFieldName( fieldName) : 
since

1.7.0

Arguments

fieldName

stringThe field element name.

Response

stringThe field name

getId

Method to get the id used for the field input tag.

getId( fieldId,  fieldName) : 
since

1.7.0

Arguments

fieldId

stringThe field element id.

fieldName

stringThe field element name.

Response

stringThe id to be used for the field input tag.

getInput

Method to get the field input markup.

getInput() : 
since

1.7.0

Response

stringThe field input markup.

getLabel

Method to get the field label markup.

getLabel() : 
since

1.7.0

Response

stringThe field label markup.

getLayoutData

Method to get the data to be passed to the layout for rendering.

getLayoutData() : mixed||string|int
since

3.5

Response

array<string|int, mixed>

getLayoutPaths

Allow to override renderer include paths in child fields

getLayoutPaths() : mixed||string|int
since

3.5

Response

array<string|int, mixed>

getName

Method to get the name used for the field input tag.

getName( fieldName) : 
since

1.7.0

Arguments

fieldName

stringThe field element name.

Response

stringThe name to be used for the field input tag.

getRenderer

Get the renderer

getRenderer( layoutId = 'default') : \Joomla\CMS\Layout\FileLayout
since

3.5

Arguments

layoutId

stringId to load

Response

FileLayout

getTitle

Method to get the field title.

getTitle() : 
since

1.7.0

Response

stringThe field title.

isDebugEnabled

Is debug enabled for this field

isDebugEnabled() : 
since

3.5

Response

bool

postProcess

Method to post-process a field value.

postProcess( value,  group = null, \Joomla\Registry\Registry input = null) : 
since

4.0.0

Arguments

value

mixedThe optional value to use as the default for the field.

group

stringThe optional dot-separated form group path on which to find the field.

input

Registry|nullAn optional Registry object with the entire data set to filter against the entire form.

Response

mixedThe processed value.

render

Render a layout of this field

render( layoutId, mixed||string|int data = []) : 
since

3.5

Arguments

layoutId

stringLayout identifier

data

array<string|int, mixed>Optional data for the layout

Response

string

renderDataAttributes

Method to render data attributes to html.

renderDataAttributes() : 
since

4.0.0

Response

stringA HTML Tag Attribute string of data attribute(s)

renderField

Method to get a control group with label and input.

renderField(mixed||string|int options = []) : 
since

3.2

Arguments

options

array<string|int, mixed>Options to be passed into the rendering of the field

Response

stringA string containing the html for the control group

setForm

Method to attach a Form object to the field.

setForm(\Joomla\CMS\Form\Form form) : \Joomla\CMS\Form\FormField
since

1.7.0

Arguments

form

FormThe Form object to attach to the form field.

Response

FormFieldThe form field object so that the method can be used in a chain.

setup

Method to attach a Form object to the field.

setup(\SimpleXMLElement element,  value,  group = null) : 
since

1.7.0

Arguments

element

SimpleXMLElementThe SimpleXMLElement object representing the <field> tag for the form field object.

value

mixedThe form field value to validate.

group

stringThe field name group control value. This acts as as an array container for the field. For example if the field has name="foo" and the group value is set to "bar" then the full field name would end up being "bar[foo]".

Response

boolTrue on success.

setValue

Simple method to set the value

setValue( value) : 
since

3.2

Arguments

value

mixedValue to set

Response

void

validate

Method to validate a FormField object based on field data.

validate( value,  group = null, \Joomla\Registry\Registry input = null) : bool|\Exception
since

4.0.0

throws

InvalidArgumentException

UnexpectedValueException

Arguments

value

mixedThe optional value to use as the default for the field.

group

stringThe optional dot-separated form group path on which to find the field.

input

Registry|nullAn optional Registry object with the entire data set to validate against the entire form.

Response

bool|ExceptionBoolean true if field value is valid, Exception on failure.

Properties

description

The description text for the form field. Usually used in tooltips.

since

1.7.0

Type(s)

string

hint

The hint text for the form field used to display hint inside the field.

since

3.2

Type(s)

string

autocomplete

The autocomplete state for the form field. If 'off' element will not be automatically completed by browser.

since

3.2

Type(s)

mixed

spellcheck

The spellcheck state for the form field.

since

3.2

Type(s)

bool

autofocus

The autofocus request for the form field. If true element will be automatically focused on document load.

since

3.2

Type(s)

bool

element

The SimpleXMLElement object of the <field> XML element that describes the form field.

since

1.7.0

Type(s)

SimpleXMLElement

form

The Form object of the form attached to the form field.

since

1.7.0

Type(s)

Form

formControl

The form control prefix for field names from the Form object attached to the form field.

since

1.7.0

Type(s)

string

hidden

The hidden state for the form field.

since

1.7.0

Type(s)

bool

hiddenLabel

Should the label be hidden when rendering the form field? This may be useful if you have the label rendering in a legend in your form field itself for radio buttons in a fieldset etc.

If you use this flag you should ensure you display the label in your form (for a11y etc.)

since

4.0.0

Type(s)

bool

hiddenDescription

Should the description be hidden when rendering the form field? This may be useful if you have the description rendering in your form field itself for e.g. note fields.

since

4.0.0

Type(s)

bool

translateLabel

True to translate the field label string.

since

1.7.0

Type(s)

bool

translateDescription

True to translate the field description string.

since

1.7.0

Type(s)

bool

translateHint

True to translate the field hint string.

since

3.2

Type(s)

bool

id

The document id for the form field.

since

1.7.0

Type(s)

string

input

The input for the form field.

since

1.7.0

Type(s)

string

label

The label for the form field.

since

1.7.0

Type(s)

string

multiple

The multiple state for the form field. If true then multiple values are allowed for the field. Most often used for list field types.

since

1.7.0

Type(s)

bool

repeat

Allows extensions to create repeat elements

since

3.2

Type(s)

mixed

pattern

The pattern (Reg Ex) of value of the form field.

since

1.7.0

Type(s)

string

validationtext

The validation text of invalid value of the form field.

since

4.0.0

Type(s)

string

name

The name of the form field.

since

1.7.0

Type(s)

string

fieldname

The name of the field.

since

1.7.0

Type(s)

string

group

The group of the field.

since

1.7.0

Type(s)

string

required

The required state for the form field. If true then there must be a value for the field to be considered valid.

since

1.7.0

Type(s)

bool

disabled

The disabled state for the form field. If true then the field will be disabled and user can't interact with the field.

since

3.2

Type(s)

bool

readonly

The readonly state for the form field. If true then the field will be readonly.

since

3.2

Type(s)

bool

type

The form field type.

since

1.7.0

Type(s)

string

validate

The validation method for the form field. This value will determine which method is used to validate the value for a field.

since

1.7.0

Type(s)

string

value

The value of the form field.

since

1.7.0

Type(s)

mixed

default

The default value of the form field.

since

1.7.0

Type(s)

mixed

size

The size of the form field.

since

3.2

Type(s)

int

class

The class of the form field

since

3.2

Type(s)

mixed

labelclass

The label's CSS class of the form field

since

1.7.0

Type(s)

mixed

onchange

The javascript onchange of the form field.

since

3.2

Type(s)

string

onclick

The javascript onclick of the form field.

since

3.2

Type(s)

string

showon

The conditions to show/hide the field.

since

3.7.0

Type(s)

string

parentclass

The parent class of the field

since

4.0.0

Type(s)

string

count

The count value for generated name field

static
since

1.7.0

Type(s)

int

generated_fieldname

The string used for generated fields names

static
since

1.7.0

Type(s)

string

layout

Name of the layout being used to render the field

since

3.5

Type(s)

string

renderLayout

Layout to render the form field

Type(s)

string

renderLabelLayout

Layout to render the label

Type(s)

string

dataAttributes

The data-attribute name and values of the form field.

For example, data-action-type="click" data-action-type="change"

since

4.0.0

Type(s)

array<string|int, mixed>