Base
extends ClassDynamic
in package
Base class is the parent class for all ValidForm objects
All ValidForm classes share this base class' logic.
Tags
Table of Contents
Methods
- __call() : mixed
- Magic caller method
- __get() : mixed
- Magic getter method
- __set() : mixed
- Magic setter method
- addCondition() : mixed
- Add a new condition to the current field
- getCondition() : Condition|null
- Get element's Condition object
- getConditionRecursive() : Condition|null
- This gets the condition of a given property, just like {@see \ValidFormBuilder\Base::getCondition()}.
- getConditions() : array<string|int, mixed>
- Get the conditions collection
- getData() : mixed
- Get a value from the internal data array.
- getDynamicButtonMeta() : mixed
- This method determines wheter or not to show the 'add extra field' dynamic button based on it's parent's condition state.
- getDynamicLabelMate() : array<string|int, mixed>
- getDynamicName() : string
- Same as getName() except getDynamicName adds the current dynamic count to the fieldname as a suffix (_1, _2 etc)
- getDynamicRemoveLabelMate() : array<string|int, mixed>
- getFieldMeta() : mixed
- Get field meta property.
- getId() : string
- getLabelMeta() : string
- Get label meta property.
- getMagicMeta() : array<string|int, mixed>
- getMagicReservedMeta() : array<string|int, mixed>
- getMeta() : mixed
- Get meta property.
- getMetCondition() : null|Condition
- Only get a condition of a given type if that condition is met. If the condition is not met, this returns null
- getName() : string
- Return the (original) name of the current field.
- getParent() : Base
- getReservedFieldMeta() : array<string|int, mixed>
- getReservedLabelMeta() : array<string|int, mixed>
- getReservedMeta() : array<string|int, mixed>
- getShortLabel() : string
- Get the short label (meta 'summaryLabel') if available.
- getTipMeta() : array<string|int, mixed>
- hasCondition() : bool
- Check if the current field contains a condition object of a specific type
- hasConditions() : bool
- Check if the current object contains any conditions at all.
- isDynamic() : bool
- Check if the current field is a dynamic field.
- setConditionalMeta() : mixed
- Based on which conditions are met, corresponding metadata is set on the object.
- setConditions() : void
- setData() : bool
- Store data in the current object.
- setDynamicLabelMeta() : mixed
- Set dynamic label specific meta data
- setDynamicRemoveLabelMeta() : mixed
- Set dynamic remove label specific meta data
- setFieldMeta() : mixed
- Set field specific meta data
- setId() : void
- setLabelMeta() : mixed
- Set label specific meta data
- setMeta() : array<string|int, mixed>
- Set meta property.
- setName() : void
- setParent() : void
- setTipMeta() : mixed
- Set tip specific meta data
- toJS() : string
- Generate corresponding javascript code for this element
Methods
__call()
Magic caller method
public
__call(string $method, mixed $values) : mixed
Parameters
- $method : string
- $values : mixed
Tags
__get()
Magic getter method
public
__get(string $property) : mixed
Parameters
- $property : string
Tags
__set()
Magic setter method
public
__set(string $property, mixed $value) : mixed
Parameters
- $property : string
- $value : mixed
Tags
addCondition()
Add a new condition to the current field
public
addCondition(string $strType, bool $blnValue, array<string|int, mixed> $arrComparisons[, string $intComparisonType = ValidForm::VFORM_MATCH_ANY ]) : mixed
For examples, check Condition
Parameters
- $strType : string
-
Define the condition type. This can be either
required,visibileorenabled - $blnValue : bool
-
Define whether this condition activates if the comparison(s) are true or false.
- $arrComparisons : array<string|int, mixed>
-
An array of Comparison objects
- $intComparisonType : string = ValidForm::VFORM_MATCH_ANY
-
The comparison type. Either
ValidForm::VFORM_MATCH_ANYorValidForm::VFORM_MATCH_ALL. WithVFORM_MATCH_ANY, as soon as one of the comparisons validates the condition, the condition is enforced. WithValidForm::VFORM_MATCH_ALL, all of the comparisons must validate before the condition will be enforced.
Tags
getCondition()
Get element's Condition object
public
getCondition(string $strProperty) : Condition|null
Note: When chaining methods, always use hasCondition() first before chaining
for example getCondition()->isMet().
Parameters
- $strProperty : string
-
Condition type e.g. 'required', 'visibile' and 'enabled'
Return values
Condition|null —Found condition or null if no condition is found.
getConditionRecursive()
This gets the condition of a given property, just like {@see \ValidFormBuilder\Base::getCondition()}.
public
getConditionRecursive(string $strProperty[, Element $objContext = null ]) : Condition|null
When no condition is found on the current element, the method searches for a condition in it's parent element.
Parameters
- $strProperty : string
-
Condition type e.g.
required,visibileandenabled - $objContext : Element = null
Return values
Condition|nullgetConditions()
Get the conditions collection
public
getConditions() : array<string|int, mixed>
Return values
array<string|int, mixed>getData()
Get a value from the internal data array.
public
getData([string $strKey = null ]) : mixed
Parameters
- $strKey : string = null
-
The key of the data attribute to return
getDynamicButtonMeta()
This method determines wheter or not to show the 'add extra field' dynamic button based on it's parent's condition state.
public
getDynamicButtonMeta() : mixed
getDynamicLabelMate()
public
getDynamicLabelMate() : array<string|int, mixed>
getDynamicLabelMate() Returns the value of $__dynamiclabelmeta
Return values
array<string|int, mixed>getDynamicName()
Same as getName() except getDynamicName adds the current dynamic count to the fieldname as a suffix (_1, _2 etc)
public
getDynamicName([int $intCount = 0 ]) : string
When the dynamic count === 0, the return value equals the output of getName()
Parameters
- $intCount : int = 0
-
The dynamic count
Return values
string —The field name
getDynamicRemoveLabelMate()
public
getDynamicRemoveLabelMate() : array<string|int, mixed>
getDynamicRemoveLabelMate() Returns the value of $__dynamicremovelabelmeta
Return values
array<string|int, mixed>getFieldMeta()
Get field meta property.
public
getFieldMeta([string $property = null ][, string $fallbackValue = "" ]) : mixed
Parameters
- $property : string = null
-
Property to get from internal field meta array.
- $fallbackValue : string = ""
-
Optional fallback value if no value is found for requested property
getId()
public
getId() : string
getId() Returns the value of $__id
Return values
stringgetLabelMeta()
Get label meta property.
public
getLabelMeta([string $property = null ][, string $fallbackValue = "" ]) : string
Parameters
- $property : string = null
-
Property to get from internal label meta array.
- $fallbackValue : string = ""
-
Optional fallback value if requested property has no value
Return values
string —Property value or empty string of none is set.
getMagicMeta()
public
getMagicMeta() : array<string|int, mixed>
getMagicMeta() Returns the value of $__magicmeta
Return values
array<string|int, mixed>getMagicReservedMeta()
public
getMagicReservedMeta() : array<string|int, mixed>
getMagicReservedMeta() Returns the value of $__magicreservedmeta
Return values
array<string|int, mixed>getMeta()
Get meta property.
public
getMeta([string $property = null ][, string $fallbackValue = "" ]) : mixed
Parameters
- $property : string = null
-
Property to get from internal meta array.
- $fallbackValue : string = ""
-
Optional fallback value if requested property has no value
getMetCondition()
Only get a condition of a given type if that condition is met. If the condition is not met, this returns null
public
getMetCondition(string $strProperty) : null|Condition
Parameters
- $strProperty : string
-
Condition type e.g. 'required', 'visibile' and 'enabled'
Return values
null|ConditiongetName()
Return the (original) name of the current field.
public
getName() : string
Use getDynamicName() to get the field name + dynamic count
Return values
string —The original field name
getParent()
public
getParent() : Base
getParent() Returns the value of $__parent
Return values
BasegetReservedFieldMeta()
public
getReservedFieldMeta() : array<string|int, mixed>
getReservedFieldMeta() Returns the value of $__reservedfieldmeta
Return values
array<string|int, mixed>getReservedLabelMeta()
public
getReservedLabelMeta() : array<string|int, mixed>
getReservedLabelMeta() Returns the value of $__reservedlabelmeta
Return values
array<string|int, mixed>getReservedMeta()
public
getReservedMeta() : array<string|int, mixed>
getReservedMeta() Returns the value of $__reservedmeta
Return values
array<string|int, mixed>getShortLabel()
Get the short label (meta 'summaryLabel') if available.
public
getShortLabel() : string
Use the 'long' (regular) label as a fallback return value.
Return values
string —The short or regular element label
getTipMeta()
public
getTipMeta() : array<string|int, mixed>
getTipMeta() Returns the value of $__tipmeta
Return values
array<string|int, mixed>hasCondition()
Check if the current field contains a condition object of a specific type
public
hasCondition(string $strProperty) : bool
Parameters
- $strProperty : string
-
Condition type e.g.
required,visibileandenabled
Return values
bool —True if element has condition object set, false if not
hasConditions()
Check if the current object contains any conditions at all.
public
hasConditions() : bool
Return values
bool —True if it contains conditions, false if not.
isDynamic()
Check if the current field is a dynamic field.
public
isDynamic() : bool
Return values
bool —True if dynamic, false if not.
setConditionalMeta()
Based on which conditions are met, corresponding metadata is set on the object.
public
setConditionalMeta() : mixed
setConditions()
public
setConditions() : void
setConditions(array $value) Overwrites the value of $__conditions
setData()
Store data in the current object.
public
setData([string $strKey = null ][, mixed $varValue = null ]) : bool
This data will not be visibile in any output and will only be used for internal purposes. For example, you can store some custom data from your CMS or an other library in a field object, for later use.
Note: Using this method will overwrite any previously set data with the same key!
Parameters
- $strKey : string = null
-
The key for this storage
- $varValue : mixed = null
-
The value to store
Return values
bool —True if set successful, false if not.
setDynamicLabelMeta()
Set dynamic label specific meta data
public
setDynamicLabelMeta(string $property, mixed $value[, bool $blnOverwrite = false ]) : mixed
Parameters
- $property : string
-
Property name.
- $value : mixed
-
Property value.
- $blnOverwrite : bool = false
-
Optionally use this boolean to force an overwrite of previous property value.
Return values
mixed —The newly set value
setDynamicRemoveLabelMeta()
Set dynamic remove label specific meta data
public
setDynamicRemoveLabelMeta(string $property, mixed $value[, bool $blnOverwrite = false ]) : mixed
Parameters
- $property : string
-
Property name.
- $value : mixed
-
Property value.
- $blnOverwrite : bool = false
-
Optionally use this boolean to force an overwrite of previous property value.
Return values
mixed —The newly set value
setFieldMeta()
Set field specific meta data
public
setFieldMeta(string $property, mixed $value[, bool $blnOverwrite = false ]) : mixed
Parameters
- $property : string
-
Property name.
- $value : mixed
-
Property value.
- $blnOverwrite : bool = false
-
Optionally use this boolean to force an overwrite of previous property value.
Return values
mixed —The newly set value
setId()
public
setId() : void
setId(string $value) Overwrites the value of $__id
setLabelMeta()
Set label specific meta data
public
setLabelMeta(string $property, mixed $value[, bool $blnOverwrite = false ]) : mixed
Parameters
- $property : string
-
Property name.
- $value : mixed
-
Property value.
- $blnOverwrite : bool = false
-
Optionally use this boolean to force an overwrite of previous property value.
Return values
mixed —The newly set value
setMeta()
Set meta property.
public
setMeta(string $property, mixed $value[, bool $blnOverwrite = false ]) : array<string|int, mixed>
Parameters
- $property : string
-
Property name.
- $value : mixed
-
Property value.
- $blnOverwrite : bool = false
-
Optionally use this boolean to force an overwrite of previous property value.
Return values
array<string|int, mixed>setName()
public
setName() : void
setName(string $value) Overwrites the value of $__name
setParent()
public
setParent() : void
setParent(Base $value) Overwrites the value of $__parent
setTipMeta()
Set tip specific meta data
public
setTipMeta(string $property, mixed $value[, bool $blnOverwrite = false ]) : mixed
Parameters
- $property : string
-
Property name.
- $value : mixed
-
Property value.
- $blnOverwrite : bool = false
-
Optionally use this boolean to force an overwrite of previous property value.
Return values
mixed —The newly set value
toJS()
Generate corresponding javascript code for this element
public
toJS([int $intDynamicPosition = 0 ]) : string
Should be extended by child classes.
Parameters
- $intDynamicPosition : int = 0
-
Dynamic position