Fields
in package
Form fields config class
Tags
Table of Contents
Constants
- INPUT_ELEMENT_TYPES = ['color' => \Pop\Form\Element\Input\Color::class, 'date' => \Pop\Form\Element\Input\Date::class, 'email' => \Pop\Form\Element\Input\Email::class, 'file' => \Pop\Form\Element\Input\File::class, 'hidden' => \Pop\Form\Element\Input\Hidden::class, 'month' => \Pop\Form\Element\Input\Month::class, 'password' => \Pop\Form\Element\Input\Password::class, 'reset' => \Pop\Form\Element\Input\Reset::class, 'search' => \Pop\Form\Element\Input\Search::class, 'submit' => \Pop\Form\Element\Input\Submit::class, 'tel' => \Pop\Form\Element\Input\Tel::class, 'text' => \Pop\Form\Element\Input\Text::class, 'time' => \Pop\Form\Element\Input\Time::class, 'url' => \Pop\Form\Element\Input\Url::class, 'week' => \Pop\Form\Element\Input\Week::class]
- Map of field 'type' string => concrete input element class, for the input types that only need the standard (name, value, indent) constructor signature.
Methods
- create() : AbstractElement
- Static factory method to create a field element object from a field config array
- getConfigFromTable() : array<string|int, mixed>
- Static factory method to get field configs from a database table
Constants
INPUT_ELEMENT_TYPES
Map of field 'type' string => concrete input element class, for the input types that only need the standard (name, value, indent) constructor signature.
private
array<string, class-string>
INPUT_ELEMENT_TYPES
= ['color' => \Pop\Form\Element\Input\Color::class, 'date' => \Pop\Form\Element\Input\Date::class, 'email' => \Pop\Form\Element\Input\Email::class, 'file' => \Pop\Form\Element\Input\File::class, 'hidden' => \Pop\Form\Element\Input\Hidden::class, 'month' => \Pop\Form\Element\Input\Month::class, 'password' => \Pop\Form\Element\Input\Password::class, 'reset' => \Pop\Form\Element\Input\Reset::class, 'search' => \Pop\Form\Element\Input\Search::class, 'submit' => \Pop\Form\Element\Input\Submit::class, 'tel' => \Pop\Form\Element\Input\Tel::class, 'text' => \Pop\Form\Element\Input\Text::class, 'time' => \Pop\Form\Element\Input\Time::class, 'url' => \Pop\Form\Element\Input\Url::class, 'week' => \Pop\Form\Element\Input\Week::class]
This is an explicit allowlist rather than resolving
Pop\Form\Element\Input\{Ucfirst($type)} dynamically via class_exists() — that
pattern would instantiate any class sitting in that namespace from a
config-supplied string, including non-element classes (e.g. Element\Input\Exception),
with no check afterward that the result is actually an AbstractElement.
Methods
create()
Static factory method to create a field element object from a field config array
public
static create(string $name, array<string|int, mixed> $field) : AbstractElement
Parameters
- $name : string
- $field : array<string|int, mixed>
Tags
Return values
AbstractElementgetConfigFromTable()
Static factory method to get field configs from a database table
public
static getConfigFromTable(array<string|int, mixed> $tableInfo[, array<string|int, mixed>|null $attribs = null ][, array<string|int, mixed>|null $config = null ][, mixed $omit = null ]) : array<string|int, mixed>
Parameters
- $tableInfo : array<string|int, mixed>
- $attribs : array<string|int, mixed>|null = null
- $config : array<string|int, mixed>|null = null
- $omit : mixed = null