PHP Class FOF30\Form\Form

Since: 2.0
Inheritance: extends JFor\JForm
Afficher le fichier Open project: akeeba/fof Class Usage Examples

Protected Properties

Свойство Type Description
$container FOF30\Container\Container The Container this form belongs to
$entities array Prototypes for all fields and rules are here. Array's structure: entities: {ENTITY_NAME}: {KEY}: {OBJECT}
$model FOF30\Model\DataModel The model attached to this view
$view FOF30\View\DataView\DataViewInterface The view used to render this form

Méthodes publiques

Méthode Description
__construct ( Container $container, string $name, array $options = [] ) Method to instantiate the form object.
addFieldPath ( string $new = null ) : void WARNING: THIS IS IGNORED IN FOF3!
addFormPath ( string $new = null ) : void WARNING: THIS IS IGNORED IN FOF3!
addHeaderPath ( string $new = null ) : void WARNING: THIS IS IGNORED IN FOF3!
addRulePath ( string $new = null ) : void WARNING: THIS IS IGNORED IN FOF3!
bind ( mixed $data ) : boolean Method to bind data to the form.
getAttribute ( string $attribute, mixed $default = null ) : mixed Returns the value of an attribute of the form itself
getContainer ( ) : Container Get a reference to the form's Container
getData ( ) : JRegistry Returns a reference to the protected $data object, allowing direct access to and manipulation of the form's data.
getHeader ( string $name, string $group = null, mixed $value = null ) : FOF30\Form\HeaderInterface | boolean Method to get a header field represented as a HeaderInterface object.
getHeaderset ( ) : array Method to get an array of FormHeader objects in the headerset.
getModel ( ) : DataModel Returns the DataModel attached to this form
getView ( ) : FOF30\View\DataView\DataViewInterface Returns the DataViewInterface attached to this form
loadCSSFiles ( ) : void Loads the CSS files defined in the form, based on its cssfiles attribute
loadClass ( string $entity, string $type ) : mixed Load a class for one of the form's entities of a particular type.
loadFile ( string $file, boolean $reset = true, boolean $xpath = false ) : boolean Method to load the form description from an XML file.
loadJSFiles ( ) : void Loads the Javascript files defined in the form, based on its jsfiles attribute
removeHeader ( string $name, string $group = null ) : boolean Method to remove a header from the form definition.
setContainer ( Container $container ) Set the form's Container
setModel ( DataModel &$model ) : void Attaches a DataModel to this form
setView ( FOF30\View\DataView\DataViewInterface &$view ) : void Attaches a DataViewInterface to this form

Méthodes protégées

Méthode Description
bindLevel ( string $group, mixed $data ) : void Method to bind data to the form for the group level.
findField ( string $name, string $group = null ) : mixed Method to get a form field represented as an XML element object.
findHeader ( string $name, string $group = null ) : mixed Method to get a header field represented as an XML element object.
findHeadersByGroup ( mixed $group = null, boolean $nested = false ) : SimpleXMLElement | boolean Method to get an array of
elements from the form XML document which are in a control group by name.
loadField ( string $element, string $group = null, mixed $value = null ) : mixed Method to load, setup and return a JFormField object based on field data.
loadFieldType ( string $type, boolean $new = true ) : FOF30\Form\FieldInterface | boolean Proxy for {@link Helper::loadFieldType()}.
loadHeader ( string $element, string $group = null ) : FOF30\Form\HeaderInterface | boolean Method to load, setup and return a HeaderInterface object based on field data.
loadHeaderType ( string $type, boolean $new = true ) : FOF30\Form\HeaderInterface | boolean Proxy for {@link Helper::loadHeaderType()}.
loadRuleType ( string $type, boolean $new = true ) : JFormRule | boolean Proxy for {@link Helper::loadRuleType()}.
loadType ( string $entity, string $type, boolean $new = true ) : mixed Method to load a form entity object given a type.
modelToBindSource ( DataModel $model, integer $maxLevel = 1, array $modelsProcessed = [] ) : array Converts a DataModel into data suitable for use with the form. The difference to the Model's getData() method is that we process hasOne and belongsTo relations. This is a recursive function which will be called at most $maxLevel deep. You can set this in the form XML file, in the relation_depth attribute.

Method Details

__construct() public méthode

Method to instantiate the form object.
public __construct ( Container $container, string $name, array $options = [] )
$container FOF30\Container\Container The component Container where this form belongs to
$name string The name of the form.
$options array An array of form options.

addFieldPath() public static méthode

WARNING: THIS IS IGNORED IN FOF3!
Deprecation: 3.0
public static addFieldPath ( string $new = null ) : void
$new string IGNORED!
Résultat void

addFormPath() public static méthode

WARNING: THIS IS IGNORED IN FOF3!
Deprecation: 3.0
public static addFormPath ( string $new = null ) : void
$new string IGNORED!
Résultat void

addHeaderPath() public static méthode

WARNING: THIS IS IGNORED IN FOF3!
Deprecation: 3.0
public static addHeaderPath ( string $new = null ) : void
$new string IGNORED!
Résultat void

addRulePath() public static méthode

WARNING: THIS IS IGNORED IN FOF3!
Deprecation: 3.0
public static addRulePath ( string $new = null ) : void
$new string IGNORED!
Résultat void

bind() public méthode

Method to bind data to the form.
Since: 11.1
public bind ( mixed $data ) : boolean
$data mixed An array or object of data to bind to the form.
Résultat boolean True on success.

bindLevel() protected méthode

Method to bind data to the form for the group level.
Since: 11.1
protected bindLevel ( string $group, mixed $data ) : void
$group string The dot-separated form group path on which to bind the data.
$data mixed An array or object of data to bind to the form for the group level.
Résultat void

findField() protected méthode

Method to get a form field represented as an XML element object.
Since: 11.1
protected findField ( string $name, string $group = null ) : mixed
$name string The name of the form field.
$group string The optional dot-separated form group path on which to find the field.
Résultat mixed The XML element object for the field or boolean false on error.

findHeader() protected méthode

Method to get a header field represented as an XML element object.
Since: 2.0
protected findHeader ( string $name, string $group = null ) : mixed
$name string The name of the form field.
$group string The optional dot-separated form group path on which to find the field.
Résultat mixed The XML element object for the field or boolean false on error.

findHeadersByGroup() protected méthode

Method to get an array of
elements from the form XML document which are in a control group by name.
Since: 2.0
protected findHeadersByGroup ( mixed $group = null, boolean $nested = false ) : SimpleXMLElement | boolean
$group mixed The optional dot-separated form group path on which to find the fields. Null will return all fields. False will return fields not in a group.
$nested boolean True to also include fields in nested groups that are inside of the group for which to find fields.
Résultat SimpleXMLElement | boolean Boolean false on error or array of SimpleXMLElement objects.

getAttribute() public méthode

Returns the value of an attribute of the form itself
Since: 2.0
public getAttribute ( string $attribute, mixed $default = null ) : mixed
$attribute string The name of the attribute
$default mixed Optional default value to return
Résultat mixed

getContainer() public méthode

Get a reference to the form's Container
public getContainer ( ) : Container
Résultat FOF30\Container\Container

getData() public méthode

Returns a reference to the protected $data object, allowing direct access to and manipulation of the form's data.
Since: 2.0
public getData ( ) : JRegistry
Résultat JRegistry The form's data registry

getHeader() public méthode

Method to get a header field represented as a HeaderInterface object.
Since: 2.0
public getHeader ( string $name, string $group = null, mixed $value = null ) : FOF30\Form\HeaderInterface | boolean
$name string The name of the header field.
$group string The optional dot-separated form group path on which to find the field.
$value mixed The optional value to use as the default for the field. (DEPRECATED)
Résultat FOF30\Form\HeaderInterface | boolean The HeaderInterface object for the field or boolean false on error.

getHeaderset() public méthode

Method to get an array of FormHeader objects in the headerset.
Since: 2.0
public getHeaderset ( ) : array
Résultat array The array of HeaderInterface objects in the headerset.

getModel() public méthode

Returns the DataModel attached to this form
public getModel ( ) : DataModel
Résultat FOF30\Model\DataModel

getView() public méthode

Returns the DataViewInterface attached to this form
public getView ( ) : FOF30\View\DataView\DataViewInterface
Résultat FOF30\View\DataView\DataViewInterface

loadCSSFiles() public méthode

Loads the CSS files defined in the form, based on its cssfiles attribute
Since: 2.0
public loadCSSFiles ( ) : void
Résultat void

loadClass() public méthode

Currently, it makes sense to use this method for the "field" and "rule" entities (but you can support more entities in your subclass).
Since: 2.0
public loadClass ( string $entity, string $type ) : mixed
$entity string One of the form entities (field, header or rule).
$type string Type of an entity.
Résultat mixed Class name on success or false otherwise.

loadField() protected méthode

Method to load, setup and return a JFormField object based on field data.
Since: 11.1
protected loadField ( string $element, string $group = null, mixed $value = null ) : mixed
$element string The XML element object representation of the form field.
$group string The optional dot-separated form group path on which to find the field.
$value mixed The optional value to use as the default for the field.
Résultat mixed The JFormField object for the field or boolean false on error.

loadFieldType() protected méthode

Proxy for {@link Helper::loadFieldType()}.
Since: 2.0
protected loadFieldType ( string $type, boolean $new = true ) : FOF30\Form\FieldInterface | boolean
$type string The field type.
$new boolean Flag to toggle whether we should get a new instance of the object.
Résultat FOF30\Form\FieldInterface | boolean FieldInterface object on success, false otherwise.

loadFile() public méthode

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.
public loadFile ( string $file, boolean $reset = true, boolean $xpath = false ) : boolean
$file string The filesystem path of an XML file.
$reset boolean Flag to toggle whether form fields should be replaced if a field already exists with the same group/name.
$xpath boolean An optional xpath to search for the fields.
Résultat boolean True on success, false otherwise.

loadHeader() protected méthode

Method to load, setup and return a HeaderInterface object based on field data.
Since: 2.0
protected loadHeader ( string $element, string $group = null ) : FOF30\Form\HeaderInterface | boolean
$element string The XML element object representation of the form field.
$group string The optional dot-separated form group path on which to find the field.
Résultat FOF30\Form\HeaderInterface | boolean The HeaderInterface object for the field or boolean false on error.

loadHeaderType() protected méthode

Proxy for {@link Helper::loadHeaderType()}.
Since: 2.0
protected loadHeaderType ( string $type, boolean $new = true ) : FOF30\Form\HeaderInterface | boolean
$type string The field type.
$new boolean Flag to toggle whether we should get a new instance of the object.
Résultat FOF30\Form\HeaderInterface | boolean HeaderInterface object on success, false otherwise.

loadJSFiles() public méthode

Loads the Javascript files defined in the form, based on its jsfiles attribute
Since: 2.0
public loadJSFiles ( ) : void
Résultat void

loadRuleType() protected méthode

Proxy for {@link Helper::loadRuleType()}.
See also: Helper::loadRuleType()
Since: 2.0
protected loadRuleType ( string $type, boolean $new = true ) : JFormRule | boolean
$type string The rule type.
$new boolean Flag to toggle whether we should get a new instance of the object.
Résultat JFormRule | boolean JFormRule object on success, false otherwise.

loadType() protected méthode

Each type is loaded only once and then used as a prototype for other objects of same type. Please, use this method only with those entities which support types (forms don't support them).
protected loadType ( string $entity, string $type, boolean $new = true ) : mixed
$entity string The entity.
$type string The entity type.
$new boolean Flag to toggle whether we should get a new instance of the object.
Résultat mixed Entity object on success, false otherwise.

modelToBindSource() protected méthode

The $modelsProcessed array which is passed in successive recursions lets us prevent pointless Inception-style recursions, e.g. Model A is related to Model B is related to Model C is related to Model A. You clearly don't care to see a.b.c.a.b in the results. You just want a.b.c. Obviously c is indirectly related to a because that's where you began the recursion anyway.
protected modelToBindSource ( DataModel $model, integer $maxLevel = 1, array $modelsProcessed = [] ) : array
$model FOF30\Model\DataModel The item to dump its contents into an array
$maxLevel integer Maximum nesting level of relations to process. Default: 1.
$modelsProcessed array Array of the fully qualified model class names already processed.
Résultat array

removeHeader() public méthode

Method to remove a header from the form definition.
public removeHeader ( string $name, string $group = null ) : boolean
$name string The name of the form field for which remove.
$group string The optional dot-separated form group path on which to find the field.
Résultat boolean True on success, false otherwise.

setContainer() public méthode

Set the form's Container
public setContainer ( Container $container )
$container FOF30\Container\Container

setModel() public méthode

Attaches a DataModel to this form
public setModel ( DataModel &$model ) : void
$model FOF30\Model\DataModel
Résultat void

setView() public méthode

Attaches a DataViewInterface to this form
public setView ( FOF30\View\DataView\DataViewInterface &$view ) : void
$view FOF30\View\DataView\DataViewInterface
Résultat void

Property Details

$container protected_oe property

The Container this form belongs to
protected Container,FOF30\Container $container
Résultat FOF30\Container\Container

$entities protected_oe property

Prototypes for all fields and rules are here. Array's structure: entities: {ENTITY_NAME}: {KEY}: {OBJECT}
protected array $entities
Résultat array

$model protected_oe property

The model attached to this view
protected DataModel,FOF30\Model $model
Résultat FOF30\Model\DataModel

$view protected_oe property

The view used to render this form
protected DataViewInterface,FOF30\View\DataView $view
Résultat FOF30\View\DataView\DataViewInterface