Form
class Form
Form Class for the Joomla Platform.
This class implements a robust API for constructing, populating, filtering, and validating forms. It uses XML definitions to construct form fields and a variety of field and rule classes to render and validate the form.
Properties
boolean | $repeat | Alows extensions to implement repeating elements |
Methods
Method to instantiate the form object.
Method to bind data to the form.
Method to filter the form data.
Return all errors, if any.
Method to get a form field represented as a JFormField object.
Method to get an attribute value from a field XML element. If the attribute doesn't exist or is null then the optional default value will be used.
Method to get an array of JFormField objects in a given fieldset by name. If no name is given then all fields are returned.
Method to get an array of fieldset objects optionally filtered over a given field group.
Method to get the form control. This string serves as a container for all form fields. For
example, if there is a field named 'foo' and a field named 'bar' and the form control is
empty the fields will be rendered like: <input name="foo" />
and <input name="bar" />
. If
the form control is set to 'joomla' however, the fields would be rendered like:
<input name="joomla[foo]" />
and <input name="joomla[bar]" />
.
Method to get an array of JFormField objects in a given field group by name.
Method to get a form field markup for the field input.
Method to get the label for a field input.
Method to get the form name.
Method to get the value of a field.
Method to get a control group with label and input.
Method to get all control groups with label and input of a fieldset.
Method to get a control group with label and input.
Method to get all control groups with label and input of a fieldset.
Method to load the form description from an XML string or object.
Method to load the form description from an XML file.
Method to remove a field from the form definition.
Method to remove a group from the form definition.
Method to reset the form data store and optionally the form XML definition.
Method to set a field XML element to the form definition. If the replace flag is set then the field will be set whether it already exists or not. If it isn't set, then the field will not be replaced if it already exists.
Method to set an attribute value for a field XML element.
Method to set some field XML elements to the form definition. If the replace flag is set then the fields will be set whether they already exists or not. If it isn't set, then the fields will not be replaced if they already exist.
Method to set the value of a field. If the field does not exist in the form then the method will return false.
Method to validate form data.
Proxy for {@link FormHelper::addFieldPath()}.
Proxy for FormHelper::addFormPath().
Proxy for FormHelper::addRulePath().
Method to get an instance of a form.
Returns the value of an attribute of the form itself
Getter for the form data
Method to get the XML form object
Method to get a form field represented as an XML element object.
Details
JFormField|boolean
getField(
string $name,
string $group = null,
mixed $value = null)
Method to get a form field represented as a JFormField object.
mixed
getFieldAttribute(
string $name,
string $attribute,
mixed $default = null,
string $group = null)
Method to get an attribute value from a field XML element. If the attribute doesn't exist or is null then the optional default value will be used.
JFormField[]
getFieldset(
string $set = null)
Method to get an array of JFormField objects in a given fieldset by name. If no name is given then all fields are returned.
array
getFieldsets(
string $group = null)
Method to get an array of fieldset objects optionally filtered over a given field group.
string
getFormControl()
Method to get the form control. This string serves as a container for all form fields. For
example, if there is a field named 'foo' and a field named 'bar' and the form control is
empty the fields will be rendered like: <input name="foo" />
and <input name="bar" />
. If
the form control is set to 'joomla' however, the fields would be rendered like:
<input name="joomla[foo]" />
and <input name="joomla[bar]" />
.
JFormField[]
getGroup(
string $group,
boolean $nested = false)
Method to get an array of JFormField objects in a given field group by name.
string
getInput(
string $name,
string $group = null,
mixed $value = null)
Method to get a form field markup for the field input.
mixed
getValue(
string $name,
string $group = null,
mixed $default = null)
Method to get the value of a field.
string
getControlGroup(
string $name,
string $group = null,
mixed $default = null)
Method to get a control group with label and input.
string
getControlGroups(
string $name)
Method to get all control groups with label and input of a fieldset.
string
renderField(
string $name,
string $group = null,
mixed $default = null,
array $options = array())
Method to get a control group with label and input.
string
renderFieldset(
string $name,
array $options = array())
Method to get all control groups with label and input of a fieldset.
boolean
load(
string $data,
string $replace = true,
string $xpath = false)
Method to load the form description from an XML string or object.
The replace option works per field. If a field being loaded already exists in the current form definition then the behavior or load will vary depending upon the replace flag. If it is set to true, then the existing field will be replaced in its exact location by the new field being loaded. If it is false, then the new field being loaded will be ignored and the method will move on to the next field to load.
boolean
loadFile(
string $file,
string $reset = true,
string $xpath = false)
Method to load the form description from an XML file.
The reset option works on a group basis. If the XML file references groups that have already been created they will be replaced with the fields in the new XML file unless the $reset parameter has been set to false.
boolean
removeField(
string $name,
string $group = null)
Method to remove a field from the form definition.
boolean
reset(
boolean $xml = false)
Method to reset the form data store and optionally the form XML definition.
boolean
setField(
SimpleXMLElement $element,
string $group = null,
boolean $replace = true,
string $fieldset = 'default')
Method to set a field XML element to the form definition. If the replace flag is set then the field will be set whether it already exists or not. If it isn't set, then the field will not be replaced if it already exists.
boolean
setFieldAttribute(
string $name,
string $attribute,
mixed $value,
string $group = null)
Method to set an attribute value for a field XML element.
boolean
setFields(
array $elements,
string $group = null,
boolean $replace = true,
string $fieldset = 'default')
Method to set some field XML elements to the form definition. If the replace flag is set then the fields will be set whether they already exists or not. If it isn't set, then the fields will not be replaced if they already exist.
boolean
setValue(
string $name,
string $group = null,
mixed $value = null)
Method to set the value of a field. If the field does not exist in the form then the method will return false.
boolean
validate(
array $data,
string $group = null)
Method to validate form data.
Validation warnings will be pushed into JForm::errors and should be retrieved with JForm::getErrors() when validate returns boolean false.
static
Form
getInstance(
string $name,
string $data = null,
array $options = array(),
boolean $replace = true,
string|boolean $xpath = false)
Method to get an instance of a form.
mixed
getAttribute(
string $name,
mixed $default = null)
Returns the value of an attribute of the form itself
SimpleXMLElement|boolean
getFieldXml(
string $name,
string $group = null)
Method to get a form field represented as an XML element object.