isDynamic()
isDynamic() : boolean
Check if multifield is dynamic
Create a Multifield element
Multifield elements allow you to combine multiple fields horizontally with one label. For example, create a first name + last name field with label "Full name"
$objMulti = $objForm->addMultifield("Full name");
// Note: when using addField on a multifield, we don't set a label!
$objMulti->addField(
"first-name",
ValidForm::VFORM_STRING,
array(),
array(),
// Keep it short, this is just a first name field
array("style" => "width: 50px")
);
$objMulti->addField("last-name", ValidForm::VFORM_STRING);
You can also combine select elements to create a date picker:
$objMulti = $objForm->addMultiField("Birthdate");
$objMulti->addField(
"year",
ValidForm::VFORM_SELECT_LIST,
array(),
array(),
array(
"start" => 1920,
"end" => 2014,
// 'fieldstyle' gets applied on the <select>
// regular 'style' applies on the wrapping <div>
"fieldstyle" => "width: 75px"
)
);
$objMulti->addField(
"month",
ValidForm::VFORM_SELECT_LIST,
array(),
array(),
array(
"start" => 01,
"end" => 12,
"fieldstyle" => "width: 75px"
)
);
$objMulti->addField(
"day",
ValidForm::VFORM_SELECT_LIST,
array(),
array(),
array(
"start" => 1,
"end" => 31,
"fieldstyle" => "width: 75px"
)
);
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.
See \ValidFormBuilder\Base::setData() for a full description
string | $strKey | The key for this storage |
mixed | $varValue | The value to store |
True if set successful, false if not.
getData(string $key = null) : mixed
Get a value from the internal data array.
See \ValidFormBuilder\Base::getData() for a full description
string | $key | The key of the data attribute to return |
If a key is provided, return it's value. If no key provided, return the whole data array. If anything is not set or incorrect, return false.
__construct(string $label, array $meta = array(), $name = null)
Create a new MultiField instance
See top of this page for examples
string | $label | The multifield's label |
array | $meta | The meta array |
$name |
addField(string $name, integer $type, array $validationRules = array(), array $errorHandlers = array(), array $meta = array()) : \ValidFormBuilder\Element
Add a field to the MultiField collection.
Same as \ValidFormBuilder\ValidForm::addField() with the only difference that the MultiField::addField()
does not take a field label since that's already set when initialising the MultiField
.
string | $name | Field name |
integer | $type | Field type |
array | $validationRules | Validation rules array |
array | $errorHandlers | Error handling array |
array | $meta | The meta array |
addText(string $strText, array $meta = array()) : \ValidFormBuilder\StaticText
Add text to the multifield.
Same as \ValidFormBuilder\ValidForm::addText()
string | $strText | The text to add (can be HTML as well) |
array | $meta | The meta array |
toHtml(boolean $submitted = false, boolean $blnSimpleLayout = false, boolean $blnLabel = true, boolean $blnDisplayError = true) : string
See {@link \ValidFormBuilder\Base::toHtml()}
boolean | $submitted | |
boolean | $blnSimpleLayout | |
boolean | $blnLabel | |
boolean | $blnDisplayError |
Generated HTML
__toHtml(boolean $submitted = false, boolean $blnSimpleLayout = false, boolean $blnLabel = true, boolean $blnDisplayError = true, integer $intCount) : string
See {@link \ValidFormBuilder\Base::__toHtml()}
boolean | $submitted | |
boolean | $blnSimpleLayout | |
boolean | $blnLabel | |
boolean | $blnDisplayError | |
integer | $intCount |
Generated HTML
getFields() : \ValidFormBuilder\Collection
Get Fields collection