Fieldset
extends AbstractElement
in package
Abstract class for form, coumn and fieldset
Table of Contents
Properties
- $_data : array<string|int, mixed>|null
- Object attributes
- $_dirty : array<string|int, mixed>
- $_elements : Collection|null
- Form level elements collection
- $_form : mixed
- $_hasDataChanges : bool
- Data changes flag (true after setData|unsetData call)
- $_id : mixed
- $_idFieldName : string
- Name of object id field
- $_isDeleted : bool
- Object delete flag
- $_oldFieldsMap : array<string|int, mixed>
- Map short fields names to its full names
- $_renderer : RendererInterface
- $_sortChildrenByKey : string
- Sort child elements by specified data key
- $_sortChildrenDirection : int
- Children sort direction
- $_syncFieldsMap : mixed
- Map of fields to sync to other fields upon changing their data
- $_type : mixed
- $_types : array<string|int, mixed>
- Element type classes
- $_underscoreCache : array<string|int, mixed>
- Setter/Getter underscore transformation cache
Methods
- __call() : mixed
- Set/Get attribute wrapper
- __construct() : mixed
- AbstractElement constructor.
- __get() : mixed
- Attribute getter (deprecated)
- __set() : mixed
- Attribute setter (deprecated)
- __toArray() : array<string|int, mixed>
- Convert object attributes to array
- addClass() : $this
- addColumn() : Column
- addData() : $this
- Add data to the object.
- addElement() : $this
- Add form element
- addElementValues() : $this
- Add specified values to element values
- addField() : AbstractElement
- Add child element
- addFieldset() : Fieldset
- addType() : $this
- debug() : string|array<string|int, mixed>
- Present object data as string in debug mode
- flagDirty() : $this
- getAfterElementHtml() : string
- getChildrenHtml() : string
- getClass() : string
- getData() : mixed
- Object data getter
- getDataByKey() : mixed
- Get object data by particular key
- getDataByPath() : mixed
- Get object data by path
- getDataSetDefault() : mixed
- Fast get data or set default if value is not available
- getDataUsingMethod() : mixed
- Get object data by key with calling getter method
- getDefaultHtml() : string
- getElementHtml() : string
- getElements() : Collection
- getEscapedValue() : string
- getForm() : Form
- getHtml() : string
- getHtmlAttributes() : array<string|int, mixed>
- getHtmlContainerId() : string
- getHtmlId() : string
- getId() : string
- Retrieve object id
- getIdFieldName() : string
- Retrieve name of object id field
- getLabel() : string
- getLabelHtml() : string
- Render HTML for element's label
- getLegend() : string
- getName() : string
- getNoSpan() : bool
- getReadonly() : bool
- getRenderer() : RendererInterface
- getRequired() : bool
- getSortedElements() : array<string|int, mixed>
- Get sorted elements as array
- getSubFieldsetHtml() : string
- getType() : string
- getUseContainer() : bool
- getValue() : string
- getValues() : array<string|int, mixed>
- hasData() : bool
- If $key is empty, checks whether there's any data in the object Otherwise checks if the specified attribute is set.
- hasDataChanges() : bool
- Get data change status
- isDeleted() : bool
- Set _isDeleted flag value (if $isDeleted param is defined) and return current flag value
- isDirty() : bool
- isEmpty() : bool
- checks whether the object is empty
- jsonSerialize() : array<string|int, mixed>
- Implementation of JsonSerializable::jsonSerialize()
- offsetExists() : bool
- Implementation of ArrayAccess::offsetExists()
- offsetGet() : mixed
- Implementation of ArrayAccess::offsetGet()
- offsetSet() : void
- Implementation of ArrayAccess::offsetSet()
- offsetUnset() : void
- Implementation of ArrayAccess::offsetUnset()
- removeClass() : $this
- Remove CSS class
- removeField() : $this
- serialize() : string
- serialize object attributes
- setAction() : $this
- setAfterElementHtml() : $this
- setClass() : $this
- setContainer() : $this
- setData() : $this
- Overwrite data in the object.
- setDataChanges() : $this
- Clears data changes status
- setDataUsingMethod() : $this
- Set object data with calling setter method
- setDisabled() : $this
- setExtType() : $this
- setForm() : $this
- setId() : $this
- Set object id field value
- setIdFieldName() : $this
- set name of object id field
- setLabel() : $this
- setMethod() : $this
- setName() : $this
- setReadonly() : $this
- Disable elements
- setRenderer() : $this
- setRequired() : $this
- setSortElementsByAttribute() : Fieldset
- Commence sorting elements by values by specified data key
- setType() : $this
- setUseContainer() : $this
- setValue() : $this
- setValues() : $this
- toArray() : array<string|int, mixed>
- Public wrapper for __toArray
- toHtml() : string
- toJson() : string
- Public wrapper for __toJson
- toString() : string
- Public wrapper for __toString
- toXml() : string
- Public wrapper for __toXml
- unsCanUseDefaultValue() : $this
- unsCanUseWebsiteValue() : $this
- unsetData() : $this
- Unset data from the object.
- unsetOldData() : $this
- Unset old fields data from the object.
- unsScope() : $this
- __toJson() : string
- Convert object attributes to JSON
- __toXml() : string
- Convert object attributes to XML
- _addFullNames() : mixed
- _camelize() : string
- _construct() : void
- Internal constructor not depended on params. Can be used for object initialization
- _escape() : string
- _getData() : mixed
- Get value from _data array without parse key
- _initOldFieldsMap() : mixed
- Inits mapping array of object's previously used fields to new fields.
- _prepareArray() : array<string|int, mixed>
- Set required array elements
- _prepareSyncFieldsMap() : $this
- Called after old fields are inited. Forms synchronization map to sync old fields and new fields between each other.
- _underscore() : string
- Converts field names for setters and getters
Properties
$_data
Object attributes
protected
array<string|int, mixed>|null
$_data
= []
$_dirty
protected
array<string|int, mixed>
$_dirty
$_elements
Form level elements collection
protected
Collection|null
$_elements
$_form
protected
mixed
$_form
$_hasDataChanges
Data changes flag (true after setData|unsetData call)
protected
bool
$_hasDataChanges
= false
$_id
protected
mixed
$_id
$_idFieldName
Name of object id field
protected
string
$_idFieldName
= null
$_isDeleted
Object delete flag
protected
bool
$_isDeleted
= false
$_oldFieldsMap
Map short fields names to its full names
protected
array<string|int, mixed>
$_oldFieldsMap
= []
$_renderer
protected
RendererInterface
$_renderer
$_sortChildrenByKey
Sort child elements by specified data key
protected
string
$_sortChildrenByKey
= ''
$_sortChildrenDirection
Children sort direction
protected
int
$_sortChildrenDirection
= SORT_ASC
$_syncFieldsMap
Map of fields to sync to other fields upon changing their data
protected
mixed
$_syncFieldsMap
= []
$_type
protected
mixed
$_type
$_types
Element type classes
protected
array<string|int, mixed>
$_types
= []
$_underscoreCache
Setter/Getter underscore transformation cache
protected
static array<string|int, mixed>
$_underscoreCache
= []
Methods
__call()
Set/Get attribute wrapper
public
__call(string $method, array<string|int, mixed> $args) : mixed
Parameters
- $method : string
- $args : array<string|int, mixed>
__construct()
AbstractElement constructor.
public
__construct([array<string|int, mixed> $attributes = [] ]) : mixed
Parameters
- $attributes : array<string|int, mixed> = []
__get()
Attribute getter (deprecated)
public
__get(string $var) : mixed
Parameters
- $var : string
__set()
Attribute setter (deprecated)
public
__set(string $var, mixed $value) : mixed
Parameters
- $var : string
- $value : mixed
__toArray()
Convert object attributes to array
public
__toArray([array<string|int, mixed> $arrAttributes = [] ]) : array<string|int, mixed>
Parameters
- $arrAttributes : array<string|int, mixed> = []
-
array of required attributes
Attributes
- #[Override]
Return values
array<string|int, mixed>addClass()
public
addClass(string $class) : $this
Parameters
- $class : string
Return values
$thisaddColumn()
public
addColumn(string $elementId, array<string|int, mixed> $config) : Column
Parameters
- $elementId : string
- $config : array<string|int, mixed>
Return values
ColumnaddData()
Add data to the object.
public
addData(array<string|int, mixed> $arr) : $this
Retains previous data in the object.
Parameters
- $arr : array<string|int, mixed>
Return values
$thisaddElement()
Add form element
public
addElement(AbstractElement $element[, string|false $after = false ]) : $this
Parameters
- $element : AbstractElement
- $after : string|false = false
Attributes
- #[Override]
Return values
$thisaddElementValues()
Add specified values to element values
public
addElementValues(string|int|array<string|int, mixed> $values[, bool $overwrite = false ]) : $this
Parameters
- $values : string|int|array<string|int, mixed>
- $overwrite : bool = false
Return values
$thisaddField()
Add child element
public
addField(string $elementId, string $type, array<string|int, mixed> $config[, string|false $after = false ]) : AbstractElement
Parameters
- $elementId : string
- $type : string
- $config : array<string|int, mixed>
- $after : string|false = false
Attributes
- #[Override]
Return values
AbstractElementaddFieldset()
public
addFieldset(string $elementId, array<string|int, mixed> $config[, bool|string|null $after = false ]) : Fieldset
Parameters
- $elementId : string
- $config : array<string|int, mixed>
- $after : bool|string|null = false
Return values
FieldsetaddType()
public
addType(string $type, string $className) : $this
Parameters
- $type : string
- $className : string
Return values
$thisdebug()
Present object data as string in debug mode
public
debug([mixed $data = null ][, array<string|int, mixed> &$objects = [] ]) : string|array<string|int, mixed>
Parameters
- $data : mixed = null
- $objects : array<string|int, mixed> = []
Return values
string|array<string|int, mixed>flagDirty()
public
flagDirty(string $field[, bool $flag = true ]) : $this
Parameters
- $field : string
- $flag : bool = true
Return values
$thisgetAfterElementHtml()
public
getAfterElementHtml() : string
Return values
stringgetChildrenHtml()
public
getChildrenHtml() : string
Return values
stringgetClass()
public
getClass() : string
Return values
stringgetData()
Object data getter
public
getData([string $key = '' ][, string|int $index = null ]) : mixed
If $key is not defined will return all the data as an array. Otherwise, it will return value of the element specified by $key. It is possible to use keys like a/b/c for access nested array data
If $index is specified it will assume that attribute data is an array and retrieve corresponding member. If data is the string - it will be explode by new line character and converted to array.
Parameters
- $key : string = ''
- $index : string|int = null
getDataByKey()
Get object data by particular key
public
getDataByKey(string $key) : mixed
Parameters
- $key : string
getDataByPath()
Get object data by path
public
getDataByPath(string $path) : mixed
Method consider the path as chain of keys: a/b/c => ['a']['b']['c']
Parameters
- $path : string
getDataSetDefault()
Fast get data or set default if value is not available
public
getDataSetDefault(string $key, mixed $default) : mixed
Parameters
- $key : string
- $default : mixed
getDataUsingMethod()
Get object data by key with calling getter method
public
getDataUsingMethod(string $key[, mixed $args = null ]) : mixed
Parameters
- $key : string
- $args : mixed = null
getDefaultHtml()
public
getDefaultHtml() : string
Attributes
- #[Override]
Return values
stringgetElementHtml()
public
getElementHtml() : string
Attributes
- #[Override]
Return values
stringgetElements()
public
getElements() : Collection
Return values
CollectiongetEscapedValue()
public
getEscapedValue([string|null $index = null ]) : string
Parameters
- $index : string|null = null
Return values
stringgetForm()
public
getForm() : Form
Return values
FormgetHtml()
public
getHtml() : string
Return values
stringgetHtmlAttributes()
public
getHtmlAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>getHtmlContainerId()
public
getHtmlContainerId() : string
Return values
stringgetHtmlId()
public
getHtmlId() : string
Return values
stringgetId()
Retrieve object id
public
getId() : string
Attributes
- #[Override]
Return values
stringgetIdFieldName()
Retrieve name of object id field
public
getIdFieldName() : string
Return values
stringgetLabel()
public
getLabel() : string
Return values
stringgetLabelHtml()
Render HTML for element's label
public
getLabelHtml([string $idSuffix = '' ]) : string
Parameters
- $idSuffix : string = ''
Return values
stringgetLegend()
public
getLegend() : string
Return values
stringgetName()
public
getName() : string
Return values
stringgetNoSpan()
public
getNoSpan() : bool
Return values
boolgetReadonly()
public
getReadonly() : bool
Return values
boolgetRenderer()
public
getRenderer() : RendererInterface
Return values
RendererInterfacegetRequired()
public
getRequired() : bool
Return values
boolgetSortedElements()
Get sorted elements as array
public
getSortedElements() : array<string|int, mixed>
Return values
array<string|int, mixed>getSubFieldsetHtml()
public
getSubFieldsetHtml() : string
Return values
stringgetType()
public
getType() : string
Return values
stringgetUseContainer()
public
getUseContainer() : bool
Return values
boolgetValue()
public
getValue() : string
Return values
stringgetValues()
public
getValues() : array<string|int, mixed>
Return values
array<string|int, mixed>hasData()
If $key is empty, checks whether there's any data in the object Otherwise checks if the specified attribute is set.
public
hasData([string $key = '' ]) : bool
Parameters
- $key : string = ''
Return values
boolhasDataChanges()
Get data change status
public
hasDataChanges() : bool
Return values
boolisDeleted()
Set _isDeleted flag value (if $isDeleted param is defined) and return current flag value
public
isDeleted([bool $isDeleted = null ]) : bool
Parameters
- $isDeleted : bool = null
Return values
boolisDirty()
public
isDirty([string $field = null ]) : bool
Parameters
- $field : string = null
Return values
boolisEmpty()
checks whether the object is empty
public
isEmpty() : bool
Return values
booljsonSerialize()
Implementation of JsonSerializable::jsonSerialize()
public
jsonSerialize() : array<string|int, mixed>
Prepares the object data for JSON serialization. Returns all object data as an array, with special handling for nested DataObject instances:
- If a nested DataObject has a custom jsonSerialize() implementation, it's preserved as-is
- If a nested DataObject has a custom toJson() method, it's converted to JSON string
- If a nested DataObject uses only the base implementations, it's excluded from output
This prevents infinite recursion and circular references when serializing object hierarchies.
Attributes
- #[Override]
Return values
array<string|int, mixed>offsetExists()
Implementation of ArrayAccess::offsetExists()
public
offsetExists(string $offset) : bool
Parameters
- $offset : string
Tags
Attributes
- #[Override]
Return values
booloffsetGet()
Implementation of ArrayAccess::offsetGet()
public
offsetGet(string $offset) : mixed
Parameters
- $offset : string
Tags
Attributes
- #[Override]
- #[ReturnTypeWillChange]
offsetSet()
Implementation of ArrayAccess::offsetSet()
public
offsetSet(string $offset, mixed $value) : void
Parameters
- $offset : string
- $value : mixed
Tags
Attributes
- #[Override]
offsetUnset()
Implementation of ArrayAccess::offsetUnset()
public
offsetUnset(string $offset) : void
Parameters
- $offset : string
Tags
Attributes
- #[Override]
removeClass()
Remove CSS class
public
removeClass(string $class) : $this
Parameters
- $class : string
Return values
$thisremoveField()
public
removeField(string|null $elementId) : $this
Parameters
- $elementId : string|null
Attributes
- #[Override]
Return values
$thisserialize()
serialize object attributes
public
serialize([mixed $attributes = [] ][, mixed $valueSeparator = '=' ][, mixed $fieldSeparator = ' ' ][, mixed $quote = '"' ]) : string
Parameters
- $attributes : mixed = []
- $valueSeparator : mixed = '='
- $fieldSeparator : mixed = ' '
- $quote : mixed = '"'
Attributes
- #[Override]
Return values
stringsetAction()
public
setAction(string $value) : $this
Parameters
- $value : string
Return values
$thissetAfterElementHtml()
public
setAfterElementHtml(string $value) : $this
Parameters
- $value : string
Return values
$thissetClass()
public
setClass(string $value) : $this
Parameters
- $value : string
Return values
$thissetContainer()
public
setContainer(Form $value) : $this
Parameters
- $value : Form
Return values
$thissetData()
Overwrite data in the object.
public
setData(string|array<string|int, mixed> $key[, mixed $value = null ]) : $this
$key can be string or array. If $key is string, the attribute value will be overwritten by $value
If $key is an array, it will overwrite all the data in the object.
Parameters
- $key : string|array<string|int, mixed>
- $value : mixed = null
Return values
$thissetDataChanges()
Clears data changes status
public
setDataChanges(bool $value) : $this
Parameters
- $value : bool
Return values
$thissetDataUsingMethod()
Set object data with calling setter method
public
setDataUsingMethod(string $key[, mixed $args = [] ]) : $this
Parameters
- $key : string
- $args : mixed = []
Return values
$thissetDisabled()
public
setDisabled(bool $value) : $this
Parameters
- $value : bool
Return values
$thissetExtType()
public
setExtType(string $value) : $this
Parameters
- $value : string
Return values
$thissetForm()
public
setForm(AbstractForm $form) : $this
Parameters
- $form : AbstractForm
Return values
$thissetId()
Set object id field value
public
setId(string $id) : $this
Parameters
- $id : string
Attributes
- #[Override]
Return values
$thissetIdFieldName()
set name of object id field
public
setIdFieldName(string $name) : $this
Parameters
- $name : string
Return values
$thissetLabel()
public
setLabel(string $value) : $this
Parameters
- $value : string
Return values
$thissetMethod()
public
setMethod(string $value) : $this
Parameters
- $value : string
Return values
$thissetName()
public
setName(string $value) : $this
Parameters
- $value : string
Return values
$thissetReadonly()
Disable elements
public
setReadonly(bool $readonly[, bool $useDisabled = false ]) : $this
Parameters
- $readonly : bool
- $useDisabled : bool = false
Return values
$thissetRenderer()
public
setRenderer(RendererInterface $renderer) : $this
Parameters
- $renderer : RendererInterface
Return values
$thissetRequired()
public
setRequired(bool $value) : $this
Parameters
- $value : bool
Return values
$thissetSortElementsByAttribute()
Commence sorting elements by values by specified data key
public
setSortElementsByAttribute(string $key[, int $direction = SORT_ASC ]) : Fieldset
Parameters
- $key : string
- $direction : int = SORT_ASC
Return values
FieldsetsetType()
public
setType(string $type) : $this
Parameters
- $type : string
Return values
$thissetUseContainer()
public
setUseContainer(bool $value) : $this
Parameters
- $value : bool
Return values
$thissetValue()
public
setValue(mixed $value) : $this
Parameters
- $value : mixed
Return values
$thissetValues()
public
setValues(array<string|int, mixed>|int|string $value) : $this
Parameters
- $value : array<string|int, mixed>|int|string
Return values
$thistoArray()
Public wrapper for __toArray
public
toArray([array<string|int, mixed> $arrAttributes = [] ]) : array<string|int, mixed>
Parameters
- $arrAttributes : array<string|int, mixed> = []
Return values
array<string|int, mixed>toHtml()
public
toHtml() : string
Return values
stringtoJson()
Public wrapper for __toJson
public
toJson([array<string|int, mixed> $arrAttributes = [] ]) : string
Parameters
- $arrAttributes : array<string|int, mixed> = []
Return values
stringtoString()
Public wrapper for __toString
public
toString([string $format = '' ]) : string
Will use $format as an template and substitute {{key}} for attributes
Parameters
- $format : string = ''
Return values
stringtoXml()
Public wrapper for __toXml
public
toXml([array<string|int, mixed> $arrAttributes = [] ][, string $rootName = 'item' ][, bool $addOpenTag = false ][, bool $addCdata = true ]) : string
Parameters
- $arrAttributes : array<string|int, mixed> = []
- $rootName : string = 'item'
- $addOpenTag : bool = false
- $addCdata : bool = true
Return values
stringunsCanUseDefaultValue()
public
unsCanUseDefaultValue() : $this
Return values
$thisunsCanUseWebsiteValue()
public
unsCanUseWebsiteValue() : $this
Return values
$thisunsetData()
Unset data from the object.
public
unsetData([string $key = null ]) : $this
$key can be a string only. Array will be ignored.
Parameters
- $key : string = null
Return values
$thisunsetOldData()
Unset old fields data from the object.
public
unsetOldData([string $key = null ]) : $this
$key can be a string only. Array will be ignored.
Parameters
- $key : string = null
Return values
$thisunsScope()
public
unsScope() : $this
Return values
$this__toJson()
Convert object attributes to JSON
protected
__toJson([array<string|int, mixed> $arrAttributes = [] ]) : string
Parameters
- $arrAttributes : array<string|int, mixed> = []
-
array of required attributes
Return values
string__toXml()
Convert object attributes to XML
protected
__toXml([array<string|int, mixed> $arrAttributes = [] ][, string $rootName = 'item' ][, bool $addOpenTag = false ][, bool $addCdata = true ]) : string
Parameters
- $arrAttributes : array<string|int, mixed> = []
-
array of required attributes
- $rootName : string = 'item'
-
name of the root element
- $addOpenTag : bool = false
- $addCdata : bool = true
Return values
string_addFullNames()
protected
_addFullNames() : mixed
_camelize()
protected
_camelize(string $name) : string
Parameters
- $name : string
Return values
string_construct()
Internal constructor not depended on params. Can be used for object initialization
protected
_construct() : void
_escape()
protected
_escape(string $string) : string
Parameters
- $string : string
Return values
string_getData()
Get value from _data array without parse key
protected
_getData(string $key) : mixed
Parameters
- $key : string
_initOldFieldsMap()
Inits mapping array of object's previously used fields to new fields.
protected
_initOldFieldsMap() : mixed
Must be overloaded by descendants to set concrete fields map.
_prepareArray()
Set required array elements
protected
_prepareArray(array<string|int, mixed> &$arr[, array<string|int, mixed> $elements = [] ]) : array<string|int, mixed>
Parameters
- $arr : array<string|int, mixed>
- $elements : array<string|int, mixed> = []
Return values
array<string|int, mixed>_prepareSyncFieldsMap()
Called after old fields are inited. Forms synchronization map to sync old fields and new fields between each other.
protected
_prepareSyncFieldsMap() : $this
Return values
$this_underscore()
Converts field names for setters and getters
protected
_underscore(string $name) : string
$this->setMyField($value) === $this->setData('my_field', $value) Uses cache to eliminate unnecessary preg_replace
Parameters
- $name : string