isDynamic()
isDynamic() : boolean
Check if the current field is a dynamic field.
Returns
boolean —True if dynamic, false if not.
Group fields together in an Area
An area is about the same as a fieldset but an Area has more interactive options like the 'active' property or even the 'dynamic' meta.
An Area can be used to group form fields together. When an Area is active, it can toggle the disabled state on all it's child form fields using the auto-generated checkbox in the Area's legend.
$objArea = $objForm->addArea("Disable fields", true, "fields-disabled");
$objArea->addField(
"first-name",
"First name",
ValidForm::VFORM_STRING,
array(
// Make this field required
"required" => true
),
array(
// Show this error to indicate this is an required field if no value is submitted
"required" => "This field is required"
)
);
$objArea->addField(
"last-name",
"Last name",
ValidForm::VFORM_STRING,
array(
// Make this field required
"required" => true
),
array(
// Show this error to indicate this is an required field if no value is submitted
"required" => "This field is required"
)
);
$objArea = $objForm->addArea("Cool area");
$objArea->addField("first-name", "First name", ValidForm::VFORM_STRING);
$objArea->addParagraph(
"Cool paragraph with lots of text in it. It's an absolute must-read.",
"You must read this"
);
addCondition(string $strType, boolean $blnValue, array $arrComparisons, string $intComparisonType = \ValidFormBuilder\ValidForm::VFORM_MATCH_ANY)
Add a new condition to the current field
For examples, check \ValidFormBuilder\Condition
string | $strType | Define the condition type. This can be either |
boolean | $blnValue | Define whether this condition activates if the comparison(s) are true or false. |
array | $arrComparisons | An array of Comparison objects |
string | $intComparisonType | The comparison type.
Either |
if Condition could not be set
If invalid arguments are supplied
getCondition(string $strProperty) : \ValidFormBuilder\Condition|null
Get element's Condition object
Note: When chaining methods, always use hasCondition() first before chaining
for example getCondition()->isMet()
.
string | $strProperty | Condition type e.g. 'required', 'visibile' and 'enabled' |
Found condition or null if no condition is found.
getMetCondition(string $strProperty) : null|\ValidFormBuilder\Condition
Only get a condition of a given type if that condition is met. If the condition is not met, this returns null
string | $strProperty | Condition type e.g. 'required', 'visibile' and 'enabled' |
getConditionRecursive(string $strProperty, \ValidFormBuilder\Element $objContext = null) : \ValidFormBuilder\Condition|null
This gets the condition of a given property, just like {@link \ValidFormBuilder\Base::getCondition()}.
When no condition is found on the current element, the method searches for a condition in it's parent element.
string | $strProperty | Condition type e.g. |
\ValidFormBuilder\Element | $objContext |
setFieldMeta(string $property, mixed $value, boolean $blnOverwrite = false) : mixed
Set field specific meta data
string | $property | Property name. |
mixed | $value | Property value. |
boolean | $blnOverwrite | Optionally use this boolean to force an overwrite of previous property value. |
The newly set value
setLabelMeta(string $property, mixed $value, boolean $blnOverwrite = false) : mixed
Set label specific meta data
string | $property | Property name. |
mixed | $value | Property value. |
boolean | $blnOverwrite | Optionally use this boolean to force an overwrite of previous property value. |
The newly set value
setTipMeta(string $property, mixed $value, boolean $blnOverwrite = false) : mixed
Set tip specific meta data
string | $property | Property name. |
mixed | $value | Property value. |
boolean | $blnOverwrite | Optionally use this boolean to force an overwrite of previous property value. |
The newly set value
setDynamicLabelMeta(string $property, mixed $value, boolean $blnOverwrite = false) : mixed
Set dynamic label specific meta data
string | $property | Property name. |
mixed | $value | Property value. |
boolean | $blnOverwrite | Optionally use this boolean to force an overwrite of previous property value. |
The newly set value
setDynamicRemoveLabelMeta(string $property, mixed $value, boolean $blnOverwrite = false) : mixed
Set dynamic remove label specific meta data
string | $property | Property name. |
mixed | $value | Property value. |
boolean | $blnOverwrite | Optionally use this boolean to force an overwrite of previous property value. |
The newly set value
getLabelMeta(string $property = null, string $fallbackValue = "") : string
Get label meta property.
string | $property | Property to get from internal label meta array. |
string | $fallbackValue | Optional fallback value if requested property has no value |
Property value or empty string of none is set.
getDynamicName(integer $intCount) : string
Same as getName() except getDynamicName adds the current dynamic count to the fieldname as a suffix (_1, _2 etc)
When the dynamic count === 0, the return value equals the output of getName()
integer | $intCount | The dynamic count |
The field name
setData(string $strKey = null, mixed $varValue = null) : boolean
Store data in the current object.
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!
string | $strKey | The key for this storage |
mixed | $varValue | The value to store |
True if set successful, false if not.
__construct(string $label, boolean $active = false, string $name = null, boolean $checked = false, array $meta = array())
Create a new Area instance
The label is used as a small 'header' above the area. When setting an area to 'active', this label becomes clickable using a checkbox. This clickable header can toggle child fields to be enabled / disabled.
string | $label | The Area's label |
boolean | $active | Whether the area should be active or not. When active, a checkbox will be prefixed to the header. |
string | $name | The name for this area |
boolean | $checked | Whether or not the active area should be checked by default |
array | $meta | The optional meta array |
addField(string $name, string $label, integer $type, array $validationRules = array(), array $errorHandlers = array(), array $meta = array()) : null|\ValidFormBuilder\Element
Add a field to the Area.
See top of the page for an example
string | $name | |
string | $label | |
integer | $type | One of the ValidForm::VFORM_ field types |
array | $validationRules | Standard validation rules array |
array | $errorHandlers | Standard error handler array |
array | $meta | Standard meta array |
Returns an instance of the field type generated
addParagraph(string $strBody, string $strHeader = "", array $meta = array()) : \ValidFormBuilder\Paragraph
Add paragraph to Area
$objArea->addParagraph(
"Cool paragraph with lots of text in it. It's an absolute must-read.",
"You must read this"
);
string | $strBody | The paragraph's body text |
string | $strHeader | The paragraph's optional header |
array | $meta | Standard meta array |
addMultiField(string $label = null, array $meta = array()) : \ValidFormBuilder\MultiField
Add a multifield to the Area
string | $label | The multifield's label |
array | $meta | The standard meta array |
toHtml(boolean $submitted = false, boolean $blnSimpleLayout = false, boolean $blnLabel = true, boolean $blnDisplayErrors = true) : string
Render the Area and it's children with toHtml()
boolean | $submitted | Define if the area has been submitted and propagate that flag to the child fields |
boolean | $blnSimpleLayout | Only render in simple layout mode |
boolean | $blnLabel | |
boolean | $blnDisplayErrors | Display generated errors |
Rendered Area
getFields() : \ValidFormBuilder\Collection
Return all children in a Collection