ValidForm Builder API Documentation

StaticText extends Base
in package

Injects a string in the form.

Use this to add an extra string in the form. For instance, you can create an input field like this:

Enter the amount:   $ _____

In this example, we used StaticText to inject the dollar sign before our input field.

Tags
author

Felix Langfeldt [email protected]

author

Robin van Baalen [email protected]

version
5.3.0

Table of Contents

Methods

__call()  : mixed
Magic caller method
__construct()  : mixed
Create new StaticText instance
__get()  : mixed
Magic getter method
__set()  : mixed
Magic setter method
__toHtml()  : string
Render the string's HTML
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()  : void
Get information from 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()  : void
Get string name
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>
getValidator()  : null
Get validator object
getValue()  : void
Get string value
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.
hasFields()  : bool
Check if string has fields
isDynamic()  : bool
Check if string is dynamic
isValid()  : bool
Validate string
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
toHtml()  : mixed
Render the string's HTML
toJS()  : string
Render the string's Javascript

Methods

__call()

Magic caller method

public __call(string $method, mixed $values) : mixed
Parameters
$method : string
$values : mixed
Tags
throws
BadMethodCallException

__construct()

Create new StaticText instance

public __construct(string $bodyString[, array<string|int, mixed> $meta = array() ]) : mixed
Parameters
$bodyString : string

The string to inject. Can be a simple string or even HTML code.

$meta : array<string|int, mixed> = array()

The meta array

__get()

Magic getter method

public __get(string $property) : mixed
Parameters
$property : string
Tags
throws
BadMethodCallException

__set()

Magic setter method

public __set(string $property, mixed $value) : mixed
Parameters
$property : string
$value : mixed
Tags
throws
BadMethodCallException

__toHtml()

Render the string's HTML

public __toHtml([bool $submitted = false ][, bool $blnSimpleLayout = false ]) : string
Parameters
$submitted : bool = false

Force 'submitted' behavior

$blnSimpleLayout : bool = false

Force simple layout

Return values
string

The generated HTML output

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, visibile or enabled

$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_ANY or ValidForm::VFORM_MATCH_ALL. With VFORM_MATCH_ANY, as soon as one of the comparisons validates the condition, the condition is enforced. With ValidForm::VFORM_MATCH_ALL, all of the comparisons must validate before the condition will be enforced.

Tags
throws
Exception

if Condition could not be set

throws
InvalidArgumentException

If invalid arguments are supplied

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, visibile and enabled

$objContext : Element = null
Return values
Condition|null

getConditions()

Get the conditions collection

public getConditions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getData()

Get information from data array

public getData([mixed $strKey = null ]) : void

Not applicable for StaticText objects.

Parameters
$strKey : mixed = 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
string

getLabelMeta()

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|Condition

getName()

Get string name

public getName() : void

StaticText has no name, only an ID

getParent()

public getParent() : Base

getParent() Returns the value of $__parent

Return values
Base

getReservedFieldMeta()

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>

getValidator()

Get validator object

public getValidator() : null

Always returns null; string has no validator object

Return values
null

getValue()

Get string value

public getValue() : void

Return nothing; string has no value.

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, visibile and enabled

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.

hasFields()

Check if string has fields

public hasFields() : bool

Always returns false, string can't contain fields

Return values
bool

False

isDynamic()

Check if string is dynamic

public isDynamic() : bool
Return values
bool

False

isValid()

Validate string

public isValid() : bool
Return values
bool

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

toHtml()

Render the string's HTML

public toHtml([bool $submitted = false ][, bool $blnSimpleLayout = false ]) : mixed
Parameters
$submitted : bool = false

Force 'submitted' behavior

$blnSimpleLayout : bool = false

Force simple layout

toJS()

Render the string's Javascript

public toJS([mixed $intDynamicPosition = 0 ]) : string
Parameters
$intDynamicPosition : mixed = 0

Dynamic position

Tags
see
Base::toJS()
Return values
string

The generated HTML output


        
On this page

Search results