\ValidFormBuilderButton

Button Class

This generates a <button> element. You can customize this button using the meta array. For example, you can add a custom class property to the button like this:

$objForm->addButton(
    "Button label",
    array(
        // Set for example a Twitter Bootstrap class on this button
        "fieldclass" => "btn btn-large"
    )
);

Summary

Methods
Properties
Constants
addCondition()
setMeta()
setFieldMeta()
getFieldMeta()
setLabelMeta()
setTipMeta()
getMeta()
getLabelMeta()
getName()
toJS()
setData()
getData()
__construct()
toHtml()
isValid()
isDynamic()
hasFields()
getId()
setId()
getLabel()
setLabel()
getType()
setType()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

addCondition()

addCondition(string  $strType, boolean  $blnValue, array  $arrComparisons, integer  $intComparisonType = \ValidFormBuilder\ValidForm::VFORM_MATCH_ANY) 

Add a new condition to the current field

For examples, check \ValidFormBuilder\Condition

Parameters

string $strType

Define the condition type. This can be either required, visibile or enabled

boolean $blnValue

Define whether this condition activates if the comparison(s) are true or false.

array $arrComparisons

An array of Comparison objects

integer $intComparisonType

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.

Throws

\Exception

if Condition could not be set

\InvalidArgumentException

If invalid arguments are supplied

setMeta()

setMeta(string  $property, mixed  $value, boolean  $blnOverwrite = false) 

Set meta property.

Parameters

string $property

Property name.

mixed $value

Property value.

boolean $blnOverwrite

Optionally use this boolean to force an overwrite of previous property value.

setFieldMeta()

setFieldMeta(string  $property, mixed  $value, boolean  $blnOverwrite = false) : mixed

Set field specific meta data

Parameters

string $property

Property name.

mixed $value

Property value.

boolean $blnOverwrite

Optionally use this boolean to force an overwrite of previous property value.

Returns

mixed —

The newly set value

getFieldMeta()

getFieldMeta(string  $property = null, string  $fallbackValue = "") : mixed

Get field meta property.

Parameters

string $property

Property to get from internal field meta array.

string $fallbackValue

Optional fallback value if no value is found for requested property

Returns

mixed

setLabelMeta()

setLabelMeta(string  $property, mixed  $value, boolean  $blnOverwrite = false) : mixed

Set label specific meta data

Parameters

string $property

Property name.

mixed $value

Property value.

boolean $blnOverwrite

Optionally use this boolean to force an overwrite of previous property value.

Returns

mixed —

The newly set value

setTipMeta()

setTipMeta(string  $property, mixed  $value, boolean  $blnOverwrite = false) : mixed

Set tip specific meta data

Parameters

string $property

Property name.

mixed $value

Property value.

boolean $blnOverwrite

Optionally use this boolean to force an overwrite of previous property value.

Returns

mixed —

The newly set value

getMeta()

getMeta(string  $property = null, string  $fallbackValue = "") : mixed

Get meta property.

Parameters

string $property

Property to get from internal meta array.

string $fallbackValue

Optional fallback value if requested property has no value

Returns

mixed

getLabelMeta()

getLabelMeta(string  $property = null, string  $fallbackValue = "") : string

Get label meta property.

Parameters

string $property

Property to get from internal label meta array.

string $fallbackValue

Optional fallback value if requested property has no value

Returns

string —

Property value or empty string of none is set.

getName()

getName() : string

Return the (original) name of the current field.

Use getDynamicName() to get the field name + dynamic count

Returns

string —

The original field name

toJS()

toJS(integer  $intDynamicPosition) : string

Generate corresponding javascript code for this element

Should be extended by child classes.

Parameters

integer $intDynamicPosition

Dynamic position

Returns

string

setData()

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!

Parameters

string $strKey

The key for this storage

mixed $varValue

The value to store

Returns

boolean —

True if set successful, false if not.

getData()

getData(string  $strKey = null) : mixed

Get a value from the internal data array.

Parameters

string $strKey

The key of the data attribute to return

Returns

mixed

__construct()

__construct(string  $label, array  $meta = array()) 

Create a new Button instance

Parameters

string $label

The button's label

array $meta

The meta array

toHtml()

toHtml(boolean  $submitted = false, boolean  $blnSimpleLayout = false, boolean  $blnLabel = true, boolean  $blnDisplayErrors = true) : string

Generate the HTML output for this button

Parameters

boolean $submitted

Obsolete property only used to keep method fingerprint compatible

boolean $blnSimpleLayout

Obsolete property only used to keep method fingerprint compatible

boolean $blnLabel

Obsolete property only used to keep method fingerprint compatible

boolean $blnDisplayErrors

Obsolete property only used to keep method fingerprint compatible

Returns

string —

Generated HTML output

isValid()

isValid() : boolean

Validate this button

Returns

boolean —

Always true; buttons are always valid

isDynamic()

isDynamic() : boolean

Check if this is a dynamic element

Returns

boolean —

Always false; buttons can't be dynamic

hasFields()

hasFields() : boolean

Check if this element has child elements.

Returns

boolean —

Always false. Buttons can't have child elements

getId()

getId() : string

Returns the ID of the Button object

Returns

string

setId()

setId(mixed  $strId) : string

Overwrites the ID of the Button object

Parameters

mixed $strId

Returns

string

getLabel()

getLabel() : string

Returns the label of the Button object

Returns

string

setLabel()

setLabel(mixed  $strLabel) : string

Overwrites the label of the Button object

Parameters

mixed $strLabel

Returns

string

getType()

getType() : string

Returns the type of the Button object

Returns

string

setType()

setType(mixed  $strButtonType = 'submit') : string

Overwrites the type of the Button object. Defaults to 'submit'

Parameters

mixed $strButtonType

Returns

string