Forms\Element\AbstractElement
AbstractSource on GitHubThis is a base class for form elements
Phalcon\Forms\Element\AbstractElement- implementsPhalcon\Forms\Element\ElementInterfacePhalcon\Forms\Element\CheckPhalcon\Forms\Element\CheckGroupPhalcon\Forms\Element\DatePhalcon\Forms\Element\EmailPhalcon\Forms\Element\FilePhalcon\Forms\Element\HiddenPhalcon\Forms\Element\NumericPhalcon\Forms\Element\PasswordPhalcon\Forms\Element\RadioPhalcon\Forms\Element\RadioGroupPhalcon\Forms\Element\SelectPhalcon\Forms\Element\SubmitPhalcon\Forms\Element\TextPhalcon\Forms\Element\TextArea
Uses Phalcon\Contracts\Forms\FormsTypes · Phalcon\Contracts\Html\HtmlTypes · Phalcon\Di\Di · Phalcon\Di\DiInterface · Phalcon\Filter\Validation\ValidatorInterface · Phalcon\Forms\Exception · Phalcon\Forms\Exceptions\FormElementNameRequired · Phalcon\Forms\Exceptions\InvalidFilterType · Phalcon\Forms\Form · Phalcon\Html\TagFactory · Phalcon\Messages\MessageInterface · Phalcon\Messages\Messages · Stringable
Method Summary
public__construct(string $name,array $attributes = [])Constructor
publicstring__toString()Magic method __toString renders the widget without attributes
publicElementInterfaceaddFilter(string $filter)Adds a filter to current list of filters
publicElementInterfaceaddValidator(ValidatorInterface $validator)Adds a validator to the element
publicElementInterfaceaddValidators(array $validators,bool $merge = true)Adds a group of validators
publicElementInterfaceappendMessage(MessageInterface $message)Appends a message to the internal message list
publicElementInterfaceclear()Clears element to its default value
publicmixedgetAttribute(string $attribute,mixed $defaultValue = null)Returns the value of an attribute if present
publicarraygetAttributes()Returns the default attributes for the element
publicmixedgetDefault()Returns the default value assigned to the element
publicgetFilters()Returns the element filters
publicFormgetForm()Returns the parent form to the element
publicstring|nullgetLabel()Returns the element label
publicMessagesgetMessages()Returns the messages that belongs to the element
publicstringgetName()Returns the element name
publicTagFactory|nullgetTagFactory()Returns the tagFactory; throws exception if not present
publicmixedgetUserOption(string $option,mixed $defaultValue = null)Returns the value of an option if present
publicarraygetUserOptions()Returns the options for the element
publicValidatorInterface[]getValidators()Returns the validators registered for the element
publicmixedgetValue()Returns the element’s value
publicboolhasMessages()Checks whether there are messages attached to the element
publicstringlabel(array $attributes = [])Generate the HTML to label the element
publicstringrender(array $attributes = [])Renders the element widget returning HTML
publicElementInterfacesetAttribute(string $attribute,mixed $value)Sets a default attribute for the element
publicElementInterfacesetAttributes(array $attributes)Sets default attributes for the element
publicElementInterfacesetDefault(mixed $value)Sets a default value in case the form does not use an entity
publicElementInterfacesetFilters(mixed $filters)Sets the element filters
publicElementInterfacesetForm(Form $form)Sets the parent form to the element
publicElementInterfacesetLabel(string $label)Sets the element label
publicElementInterfacesetMessages(Messages $messages)Sets the validation messages related to the element
publicElementInterfacesetName(string $name)Sets the element name
publicstaticsetTagFactory(TagFactory $tagFactory)Sets the TagFactory
publicElementInterfacesetUserOption(string $option,mixed $value)Sets an option for the element
publicElementInterfacesetUserOptions(array $options)Sets options for the element
protectedTagFactorygetLocalTagFactory()Returns the tagFactory; throws exception if not present
Properties
protectedarray$attributes = []protectedarray$filters = []protectedForm|null$form = nullprotectedstring|null$label = nullprotectedMessages$messagesprotectedstring$method = "inputText"protectedstring$nameprotectedarray$options = []protectedTagFactory|null$tagFactory = nullprotectedarray$validators = []protectedmixed|null$value = nullMethods
__construct()
public function __construct(
string $name,
array $attributes = []
);Constructor
__toString()
public function __toString(): string;Magic method __toString renders the widget without attributes
addFilter()
public function addFilter( string $filter ): ElementInterface;Adds a filter to current list of filters
addValidator()
public function addValidator( ValidatorInterface $validator ): ElementInterface;Adds a validator to the element
addValidators()
public function addValidators(
array $validators,
bool $merge = true
): ElementInterface;Adds a group of validators
appendMessage()
public function appendMessage( MessageInterface $message ): ElementInterface;Appends a message to the internal message list
clear()
public function clear(): ElementInterface;Clears element to its default value
getAttribute()
public function getAttribute(
string $attribute,
mixed $defaultValue = null
): mixed;Returns the value of an attribute if present
getAttributes()
public function getAttributes(): array;Returns the default attributes for the element
getDefault()
public function getDefault(): mixed;Returns the default value assigned to the element
getFilters()
public function getFilters();Returns the element filters
getForm()
public function getForm(): Form;Returns the parent form to the element
getLabel()
public function getLabel(): string|null;Returns the element label
getMessages()
public function getMessages(): Messages;Returns the messages that belongs to the element The element needs to be attached to a form
getName()
public function getName(): string;Returns the element name
getTagFactory()
public function getTagFactory(): TagFactory|null;Returns the tagFactory; throws exception if not present
getUserOption()
public function getUserOption(
string $option,
mixed $defaultValue = null
): mixed;Returns the value of an option if present
getUserOptions()
public function getUserOptions(): array;Returns the options for the element
getValidators()
public function getValidators(): ValidatorInterface[];Returns the validators registered for the element
getValue()
public function getValue(): mixed;Returns the element’s value
hasMessages()
public function hasMessages(): bool;Checks whether there are messages attached to the element
label()
public function label( array $attributes = [] ): string;Generate the HTML to label the element
render()
public function render( array $attributes = [] ): string;Renders the element widget returning HTML
setAttribute()
public function setAttribute(
string $attribute,
mixed $value
): ElementInterface;Sets a default attribute for the element
setAttributes()
public function setAttributes( array $attributes ): ElementInterface;Sets default attributes for the element
setDefault()
public function setDefault( mixed $value ): ElementInterface;Sets a default value in case the form does not use an entity or there is no value available for the element in _POST
setFilters()
public function setFilters( mixed $filters ): ElementInterface;Sets the element filters
setForm()
public function setForm( Form $form ): ElementInterface;Sets the parent form to the element
setLabel()
public function setLabel( string $label ): ElementInterface;Sets the element label
setMessages()
public function setMessages( Messages $messages ): ElementInterface;Sets the validation messages related to the element
setName()
public function setName( string $name ): ElementInterface;Sets the element name
setTagFactory()
public function setTagFactory( TagFactory $tagFactory ): static;Sets the TagFactory
setUserOption()
public function setUserOption(
string $option,
mixed $value
): ElementInterface;Sets an option for the element
setUserOptions()
public function setUserOptions( array $options ): ElementInterface;Sets options for the element
getLocalTagFactory()
protected function getLocalTagFactory(): TagFactory;Returns the tagFactory; throws exception if not present
Forms\Element\Check
ClassSource on GitHubComponent INPUT[type=check] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Check
Method Summary
publicmixedgetUncheckedValue()Returns the value to bind when the checkbox is absent from submitted
publicboolhasUncheckedValue()Whether an “unchecked value” has been explicitly registered.
publicstaticsetUncheckedValue(mixed $value)Registers a value to bind when the checkbox is absent from submitted
Properties
protectedstring$method = "inputCheckbox"protectedmixed$uncheckedValue = nullprotectedbool$uncheckedValueSet = falseMethods
getUncheckedValue()
public function getUncheckedValue(): mixed;Returns the value to bind when the checkbox is absent from submitted data. Only meaningful when hasUncheckedValue() is true.
hasUncheckedValue()
public function hasUncheckedValue(): bool;Whether an “unchecked value” has been explicitly registered.
setUncheckedValue()
public function setUncheckedValue( mixed $value ): static;Registers a value to bind when the checkbox is absent from submitted data (the typical browser behavior for an unchecked input). Without this opt-in, an unchecked checkbox leaves the entity property untouched. See cphalcon issue #16982.
Forms\Element\CheckGroup
ClassSource on GitHubComponent for a group of INPUT[type=checkbox] elements.
The name is automatically suffixed with [] when not already present so that PHP collects all checked values into an array on form submission.
Options are passed as an associative array: [‘value’ => ‘Label’] or with per-item attributes: [‘value’ => [‘label’ => ‘Label’, ‘disabled’ => true]]
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\CheckGroup
Uses Phalcon\Contracts\Forms\FormsTypes · Phalcon\Contracts\Html\HtmlTypes · Phalcon\Html\TagFactory
Method Summary
public__construct(string $name,array $options = [],array $attributes = [])Constructor
publicarraygetOptions()Returns the group options
publicstringrender(array $attributes = [])Renders the checkbox group returning HTML
publicElementInterfacesetOptions(array $options)Sets the group options
Properties
protectedarray$optionsValues = []Methods
__construct()
public function __construct(
string $name,
array $options = [],
array $attributes = []
);Constructor
getOptions()
public function getOptions(): array;Returns the group options
render()
public function render( array $attributes = [] ): string;Renders the checkbox group returning HTML
setOptions()
public function setOptions( array $options ): ElementInterface;Sets the group options
Forms\Element\Date
ClassSource on GitHubComponent INPUT[type=date] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Date
Properties
protectedstring$method = "inputDate"Forms\Element\ElementInterface
InterfaceSource on GitHubInterface for Phalcon\Forms\Element classes
Phalcon\Forms\Element\ElementInterface
Uses Phalcon\Contracts\Forms\FormsTypes · Phalcon\Contracts\Html\HtmlTypes · Phalcon\Filter\Validation\ValidatorInterface · Phalcon\Forms\Form · Phalcon\Messages\MessageInterface · Phalcon\Messages\Messages
Method Summary
publicElementInterfaceaddFilter(string $filter)Adds a filter to current list of filters
publicElementInterfaceaddValidator(ValidatorInterface $validator)Adds a validator to the element
publicElementInterfaceaddValidators(array $validators,bool $merge = true)Adds a group of validators
publicElementInterfaceappendMessage(MessageInterface $message)Appends a message to the internal message list
publicElementInterfaceclear()Clears every element in the form to its default value
publicmixedgetAttribute(string $attribute,mixed $defaultValue = null)Returns the value of an attribute if present
publicarraygetAttributes()Returns the default attributes for the element
publicmixedgetDefault()Returns the default value assigned to the element
publicgetFilters()Returns the element’s filters
publicFormgetForm()Returns the parent form to the element
publicstring|nullgetLabel()Returns the element’s label
publicMessagesgetMessages()Returns the messages that belongs to the element
publicstringgetName()Returns the element’s name
publicmixedgetUserOption(string $option,mixed $defaultValue = null)Returns the value of an option if present
publicarraygetUserOptions()Returns the options for the element
publicValidatorInterface[]getValidators()Returns the validators registered for the element
publicmixedgetValue()Returns the element’s value
publicboolhasMessages()Checks whether there are messages attached to the element
publicstringlabel()Generate the HTML to label the element
publicstringrender(array $attributes = [])Renders the element widget
publicElementInterfacesetAttribute(string $attribute,mixed $value)Sets a default attribute for the element
publicElementInterfacesetAttributes(array $attributes)Sets default attributes for the element
publicElementInterfacesetDefault(mixed $value)Sets a default value in case the form does not use an entity
publicElementInterfacesetFilters(mixed $filters)Sets the element’s filters
publicElementInterfacesetForm(Form $form)Sets the parent form to the element
publicElementInterfacesetLabel(string $label)Sets the element label
publicElementInterfacesetMessages(Messages $messages)Sets the validation messages related to the element
publicElementInterfacesetName(string $name)Sets the element’s name
publicElementInterfacesetUserOption(string $option,mixed $value)Sets an option for the element
publicElementInterfacesetUserOptions(array $options)Sets options for the element
Methods
addFilter()
public function addFilter( string $filter ): ElementInterface;Adds a filter to current list of filters
addValidator()
public function addValidator( ValidatorInterface $validator ): ElementInterface;Adds a validator to the element
addValidators()
public function addValidators(
array $validators,
bool $merge = true
): ElementInterface;Adds a group of validators
appendMessage()
public function appendMessage( MessageInterface $message ): ElementInterface;Appends a message to the internal message list
clear()
public function clear(): ElementInterface;Clears every element in the form to its default value
getAttribute()
public function getAttribute(
string $attribute,
mixed $defaultValue = null
): mixed;Returns the value of an attribute if present
getAttributes()
public function getAttributes(): array;Returns the default attributes for the element
getDefault()
public function getDefault(): mixed;Returns the default value assigned to the element
getFilters()
public function getFilters();Returns the element’s filters
getForm()
public function getForm(): Form;Returns the parent form to the element
getLabel()
public function getLabel(): string|null;Returns the element’s label
getMessages()
public function getMessages(): Messages;Returns the messages that belongs to the element The element needs to be attached to a form
getName()
public function getName(): string;Returns the element’s name
getUserOption()
public function getUserOption(
string $option,
mixed $defaultValue = null
): mixed;Returns the value of an option if present
getUserOptions()
public function getUserOptions(): array;Returns the options for the element
getValidators()
public function getValidators(): ValidatorInterface[];Returns the validators registered for the element
getValue()
public function getValue(): mixed;Returns the element’s value
hasMessages()
public function hasMessages(): bool;Checks whether there are messages attached to the element
label()
public function label(): string;Generate the HTML to label the element
render()
public function render( array $attributes = [] ): string;Renders the element widget
setAttribute()
public function setAttribute(
string $attribute,
mixed $value
): ElementInterface;Sets a default attribute for the element
setAttributes()
public function setAttributes( array $attributes ): ElementInterface;Sets default attributes for the element
setDefault()
public function setDefault( mixed $value ): ElementInterface;Sets a default value in case the form does not use an entity or there is no value available for the element in _POST
setFilters()
public function setFilters( mixed $filters ): ElementInterface;Sets the element’s filters
setForm()
public function setForm( Form $form ): ElementInterface;Sets the parent form to the element
setLabel()
public function setLabel( string $label ): ElementInterface;Sets the element label
setMessages()
public function setMessages( Messages $messages ): ElementInterface;Sets the validation messages related to the element
setName()
public function setName( string $name ): ElementInterface;Sets the element’s name
setUserOption()
public function setUserOption(
string $option,
mixed $value
): ElementInterface;Sets an option for the element
setUserOptions()
public function setUserOptions( array $options ): ElementInterface;Sets options for the element
Forms\Element\Email
ClassSource on GitHubComponent INPUT[type=email] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Email
Properties
protectedstring$method = "inputEmail"Forms\Element\File
ClassSource on GitHubComponent INPUT[type=file] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\File
Properties
protectedstring$method = "inputFile"Forms\Element\Hidden
ClassSource on GitHubComponent INPUT[type=hidden] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Hidden
Properties
protectedstring$method = "inputHidden"Forms\Element\Numeric
ClassSource on GitHubComponent INPUT[type=number] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Numeric
Properties
protectedstring$method = "inputNumeric"Forms\Element\Password
ClassSource on GitHubComponent INPUT[type=password] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Password
Properties
protectedstring$method = "inputPassword"Forms\Element\Radio
ClassSource on GitHubComponent INPUT[type=radio] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Radio
Properties
protectedstring$method = "inputRadio"Forms\Element\RadioGroup
ClassSource on GitHubComponent for a group of INPUT[type=radio] elements.
Options are passed as an associative array: [‘value’ => ‘Label’] or with per-item attributes: [‘value’ => [‘label’ => ‘Label’, ‘disabled’ => true]]
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\RadioGroup
Uses Phalcon\Contracts\Forms\FormsTypes · Phalcon\Contracts\Html\HtmlTypes · Phalcon\Html\Helper\Input\RadioGroup · Phalcon\Html\TagFactory
Method Summary
public__construct(string $name,array $options = [],array $attributes = [])Constructor
publicarraygetOptions()Returns the group options
publicstringrender(array $attributes = [])Renders the radio group returning HTML
publicElementInterfacesetOptions(array $options)Sets the group options
Properties
protectedarray$optionsValues = []Methods
__construct()
public function __construct(
string $name,
array $options = [],
array $attributes = []
);Constructor
getOptions()
public function getOptions(): array;Returns the group options
render()
public function render( array $attributes = [] ): string;Renders the radio group returning HTML
setOptions()
public function setOptions( array $options ): ElementInterface;Sets the group options
Forms\Element\Select
ClassSource on GitHubComponent SELECT (choice) for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Select
Uses Phalcon\Contracts\Forms\FormsTypes · Phalcon\Contracts\Html\HtmlTypes · Phalcon\Tag\Select
Method Summary
public__construct(string $name,mixed $options = null,array $attributes = [])Constructor
publicElementInterfaceaddOption(mixed $option)Adds an option to the current options
publicgetOptions()Returns the choices’ options
publicstringrender(array $attributes = [])Renders the element widget returning HTML
publicElementInterfacesetOptions(mixed $options)Set the choice’s options
protectedarrayprepareAttributes(array $attributes = [])Returns an array of prepared attributes for Phalcon\Html\TagFactory
Properties
protectedarray|object|null$optionsValues = nullMethods
__construct()
public function __construct(
string $name,
mixed $options = null,
array $attributes = []
);Constructor
addOption()
public function addOption( mixed $option ): ElementInterface;Adds an option to the current options
getOptions()
public function getOptions();Returns the choices’ options
render()
public function render( array $attributes = [] ): string;Renders the element widget returning HTML
setOptions()
public function setOptions( mixed $options ): ElementInterface;Set the choice’s options
prepareAttributes()
protected function prepareAttributes( array $attributes = [] ): array;Returns an array of prepared attributes for Phalcon\Html\TagFactory helpers according to the element parameters
Forms\Element\Submit
ClassSource on GitHubComponent INPUT[type=submit] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Submit
Properties
protectedstring$method = "inputSubmit"Forms\Element\Text
ClassSource on GitHubComponent INPUT[type=text] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Text
Forms\Element\TextArea
ClassSource on GitHubComponent TEXTAREA for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\TextArea
Properties
protectedstring$method = "inputTextarea"Forms\Exception
ClassSource on GitHubExceptions thrown in Phalcon\Forms will use this class
\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\ElementNotInFormPhalcon\Forms\Exceptions\FormNotInLocatorPhalcon\Forms\Exceptions\FormNotRegisteredPhalcon\Forms\Exceptions\InvalidEntityPhalcon\Forms\Exceptions\InvalidFilterTypePhalcon\Forms\Exceptions\InvalidJsonSchemaPhalcon\Forms\Exceptions\JsonSchemaNotArrayPhalcon\Forms\Exceptions\NoFormElementsPhalcon\Forms\Exceptions\SchemaEntryMissingKeyPhalcon\Forms\Exceptions\SchemaEntryNotArrayPhalcon\Forms\Exceptions\UnknownFormElementTypePhalcon\Forms\Exceptions\YamlExtensionRequiredPhalcon\Forms\Exceptions\YamlSchemaNotArray
Method Summary
Methods
tagFactoryNotFound()
public static function tagFactoryNotFound(): self;usingParameterRequired()
public static function usingParameterRequired(): self;Forms\Exceptions\ElementNotInForm
ClassSource on GitHub\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\ElementNotInForm
Uses Phalcon\Forms\Exception
Method Summary
Methods
__construct()
public function __construct( string $name );Forms\Exceptions\FormElementNameRequired
ClassSource on GitHub\InvalidArgumentExceptionPhalcon\Forms\Exceptions\FormElementNameRequired
Uses InvalidArgumentException
Method Summary
Methods
__construct()
public function __construct();Forms\Exceptions\FormNotInLocator
ClassSource on GitHub\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\FormNotInLocator
Uses Phalcon\Forms\Exception
Method Summary
Methods
__construct()
public function __construct( string $name );Forms\Exceptions\FormNotRegistered
ClassSource on GitHub\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\FormNotRegistered
Uses Phalcon\Forms\Exception
Method Summary
Methods
__construct()
public function __construct( string $name );Forms\Exceptions\InvalidEntity
ClassSource on GitHub\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\InvalidEntity
Uses Phalcon\Forms\Exception
Method Summary
Methods
__construct()
public function __construct();Forms\Exceptions\InvalidFilterType
ClassSource on GitHub\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\InvalidFilterType
Uses Phalcon\Forms\Exception
Method Summary
Methods
__construct()
public function __construct();Forms\Exceptions\InvalidJsonSchema
ClassSource on GitHub\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\InvalidJsonSchema
Uses Phalcon\Forms\Exception
Method Summary
Methods
__construct()
public function __construct( string $detail );Forms\Exceptions\JsonSchemaNotArray
ClassSource on GitHub\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\JsonSchemaNotArray
Uses Phalcon\Forms\Exception
Method Summary
Methods
__construct()
public function __construct();Forms\Exceptions\NoFormElements
ClassSource on GitHub\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\NoFormElements
Uses Phalcon\Forms\Exception
Method Summary
Methods
__construct()
public function __construct();Forms\Exceptions\SchemaEntryMissingKey
ClassSource on GitHub\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\SchemaEntryMissingKey
Uses Phalcon\Forms\Exception
Method Summary
Methods
__construct()
public function __construct(
int $index,
string $key
);Forms\Exceptions\SchemaEntryNotArray
ClassSource on GitHub\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\SchemaEntryNotArray
Uses Phalcon\Forms\Exception
Method Summary
Methods
__construct()
public function __construct( int $index );Forms\Exceptions\UnknownFormElementType
ClassSource on GitHub\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\UnknownFormElementType
Uses Phalcon\Forms\Exception
Method Summary
Methods
__construct()
public function __construct( string $type );Forms\Exceptions\YamlExtensionRequired
ClassSource on GitHub\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\YamlExtensionRequired
Uses Phalcon\Forms\Exception
Method Summary
Methods
__construct()
public function __construct();Forms\Exceptions\YamlSchemaNotArray
ClassSource on GitHub\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\YamlSchemaNotArray
Uses Phalcon\Forms\Exception
Method Summary
Methods
__construct()
public function __construct();Forms\Form
ClassSource on GitHubThis component allows to build forms using an object-oriented interface
@implements Iterator<int, ElementInterface>
\stdClassPhalcon\Di\InjectablePhalcon\Forms\Form- implements\Countable,\Iterator,Phalcon\Html\Attributes\AttributesInterface
Uses Countable · Iterator · Phalcon\Contracts\Forms\FormsTypes · Phalcon\Contracts\Forms\Schema · Phalcon\Contracts\Html\HtmlTypes · Phalcon\Di\DiInterface · Phalcon\Di\Injectable · Phalcon\Filter\FilterInterface · Phalcon\Filter\Validation · Phalcon\Filter\Validation\ValidationInterface · Phalcon\Forms\Element\Check · Phalcon\Forms\Element\ElementInterface · Phalcon\Forms\Exceptions\ElementNotInForm · Phalcon\Forms\Exceptions\InvalidEntity · Phalcon\Forms\Exceptions\NoFormElements · Phalcon\Html\Attributes · Phalcon\Html\Attributes\AttributesInterface · Phalcon\Html\TagFactory · Phalcon\Messages\Messages · Phalcon\Support\Settings · Phalcon\Tag
Method Summary
public__construct(mixed $entity = null,array $userOptions = [])Phalcon\Forms\Form constructor
publicstaticadd(ElementInterface $element,string|null $position = null,bool|null $type = null)Adds an element to the form
publicstaticbind(array $data,mixed $entity = null,array $whitelist = [])Binds data to the entity
publicstaticclear(mixed $fields = null)Clears every element in the form to its default value
publicintcount()Returns the number of elements in the form
publicmixedcurrent()Returns the current element in the iterator
publicElementInterfaceget(string $name)Returns an element added to the form by its name
publicstringgetAction()Returns the form’s action
publicAttributesgetAttributes()Get Form attributes collection
publicElementInterface[]getElements()Returns the form elements added to the form
publicgetEntity()Returns the entity related to the model
publicmixed|nullgetFilteredValue(string $name)Gets a value from the internal filtered data or calls getValue(name)
publicstringgetLabel(string $name)Returns a label for an element
publicMessagesgetMessages()Returns the messages generated in the validation.
publicMessagesgetMessagesFor(string $name)Returns the messages generated for a specific element
publicTagFactory|nullgetTagFactory()Returns the tagFactory object
publicmixedgetUserOption(string $option,mixed $defaultValue = null)Returns the value of an option if present
publicarraygetUserOptions()Returns the options for the element
publicValidationInterface|nullgetValidation()return ValidationInterface|null
publicmixed|nullgetValue(string $name)Gets a value from the internal related entity or from the default value
publicarraygetWhitelist()publicboolhas(string $name)Check if the form contains an element
publicboolhasMessagesFor(string $name)Check if messages were generated for a specific element
publicboolisValid(mixed $data = null,mixed $entity = null,array $whitelist = [])Validates the form
publicintkey()Returns the current position/key in the iterator
publicstringlabel(string $name,array $attributes = [])Generate the label of an element added to the form including HTML
publicstaticload(Schema $schema,FormsLocator $locator)Loads elements into the form from a Schema source.
publicvoidnext()Moves the internal iteration pointer to the next position
publicboolremove(string $name)Removes an element from the form
publicstringrender(string $name,array $attributes = [])Renders a specific item in the form
publicvoidrewind()Rewinds the internal iterator
publicstaticsetAction(string $action)Sets the form’s action
publicstaticsetAttributes(Attributes $attributes)Set form attributes collection
publicstaticsetEntity(mixed $entity)Sets the entity related to the model
publicstaticsetTagFactory(TagFactory $tagFactory)Sets the tagFactory for the form
publicstaticsetUserOption(string $option,mixed $value)Sets an option for the form
publicstaticsetUserOptions(array $options)Sets options for the element
publicstaticsetValidation(ValidationInterface $validation)Sets the default validation
publicstaticsetWhitelist(array $whitelist)Sets the default whitelist
publicboolvalid()Check if the current element in the iterator is valid
Properties
protectedAttributesInterface|null$attributes = nullprotectedarray$data = []protectedarray$elements = []protectedarray$elementsIndexed = []protectedobject|null$entity = nullprotectedarray$filteredData = []protectedMessages$messagesprotectedarray$options = []protectedint$position = 0protectedTagFactory|null$tagFactory = nullprotectedValidationInterface|null$validation = nullprotectedarray$whitelist = []Methods
__construct()
public function __construct(
mixed $entity = null,
array $userOptions = []
);Phalcon\Forms\Form constructor
add()
public function add(
ElementInterface $element,
string|null $position = null,
bool|null $type = null
): static;Adds an element to the form
bind()
public function bind(
array $data,
mixed $entity = null,
array $whitelist = []
): static;Binds data to the entity
clear()
public function clear( mixed $fields = null ): static;Clears every element in the form to its default value
count()
public function count(): int;Returns the number of elements in the form
current()
public function current(): mixed;Returns the current element in the iterator
get()
public function get( string $name ): ElementInterface;Returns an element added to the form by its name
getAction()
public function getAction(): string;Returns the form’s action
getAttributes()
public function getAttributes(): Attributes;Get Form attributes collection
getElements()
public function getElements(): ElementInterface[];Returns the form elements added to the form
getEntity()
public function getEntity();Returns the entity related to the model
getFilteredValue()
public function getFilteredValue( string $name ): mixed|null;Gets a value from the internal filtered data or calls getValue(name)
getLabel()
public function getLabel( string $name ): string;Returns a label for an element
getMessages()
public function getMessages(): Messages;Returns the messages generated in the validation.
if ($form->isValid($_POST) == false) {
$messages = $form->getMessages();
foreach ($messages as $message) {
echo $message, "<br>";
}
}getMessagesFor()
public function getMessagesFor( string $name ): Messages;Returns the messages generated for a specific element
getTagFactory()
public function getTagFactory(): TagFactory|null;Returns the tagFactory object
getUserOption()
public function getUserOption(
string $option,
mixed $defaultValue = null
): mixed;Returns the value of an option if present
getUserOptions()
public function getUserOptions(): array;Returns the options for the element
getValidation()
public function getValidation(): ValidationInterface|null;return ValidationInterface|null
getValue()
public function getValue( string $name ): mixed|null;Gets a value from the internal related entity or from the default value
getWhitelist()
public function getWhitelist(): array;has()
public function has( string $name ): bool;Check if the form contains an element
hasMessagesFor()
public function hasMessagesFor( string $name ): bool;Check if messages were generated for a specific element
isValid()
public function isValid(
mixed $data = null,
mixed $entity = null,
array $whitelist = []
): bool;Validates the form
key()
public function key(): int;Returns the current position/key in the iterator
label()
public function label(
string $name,
array $attributes = []
): string;Generate the label of an element added to the form including HTML
load()
public function load(
Schema $schema,
FormsLocator $locator
): static;Loads elements into the form from a Schema source.
Each definition in the schema must have at least ‘type’ and ‘name’. The locator resolves the type string to an element factory; custom types can be registered on the locator with setElement().
next()
public function next(): void;Moves the internal iteration pointer to the next position
remove()
public function remove( string $name ): bool;Removes an element from the form
render()
public function render(
string $name,
array $attributes = []
): string;Renders a specific item in the form
rewind()
public function rewind(): void;Rewinds the internal iterator
setAction()
public function setAction( string $action ): static;Sets the form’s action
setAttributes()
public function setAttributes( Attributes $attributes ): static;Set form attributes collection
setEntity()
public function setEntity( mixed $entity ): static;Sets the entity related to the model
setTagFactory()
public function setTagFactory( TagFactory $tagFactory ): static;Sets the tagFactory for the form
setUserOption()
public function setUserOption(
string $option,
mixed $value
): static;Sets an option for the form
setUserOptions()
public function setUserOptions( array $options ): static;Sets options for the element
setValidation()
public function setValidation( ValidationInterface $validation ): static;Sets the default validation
setWhitelist()
public function setWhitelist( array $whitelist ): static;Sets the default whitelist
valid()
public function valid(): bool;Check if the current element in the iterator is valid
Forms\FormsLocator
ClassSource on GitHubA closure-based registry for named forms and element type factories.
Form registry (get/has/set):
Each entry is a callable fn(?object $entity): Form. Without an entity the
resolved form is cached; with an entity a fresh form is always produced.
Element registry (getElement/hasElement/setElement):
Maps type strings (e.g. ‘text’, ‘email’) to factories used by Form::load().
Each callable has the signature fn(string $name, array $options, array $attributes): ElementInterface.
Default types are seeded by getDefaultServices(). Users may add or override
types with setElement().
Phalcon\Forms\FormsLocator
Uses Phalcon\Contracts\Forms\FormsTypes · Phalcon\Forms\Element\Check · Phalcon\Forms\Element\CheckGroup · Phalcon\Forms\Element\Date · Phalcon\Forms\Element\ElementInterface · Phalcon\Forms\Element\Email · Phalcon\Forms\Element\File · Phalcon\Forms\Element\Hidden · Phalcon\Forms\Element\Numeric · Phalcon\Forms\Element\Password · Phalcon\Forms\Element\Radio · Phalcon\Forms\Element\RadioGroup · Phalcon\Forms\Element\Select · Phalcon\Forms\Element\Submit · Phalcon\Forms\Element\Text · Phalcon\Forms\Element\TextArea · Phalcon\Forms\Exceptions\FormNotInLocator · Phalcon\Forms\Exceptions\UnknownFormElementType
Method Summary
public__construct(array $definitions = [])publicFormget(string $name,mixed $entity = null)Returns the named form.
publicgetElement(string $type)Returns the factory callable for the given element type.
publicboolhas(string $name)Checks whether a named form factory is registered.
publicboolhasElement(string $type)Checks whether an element type is registered.
publicvoidset(string $name,mixed $factory)Registers or replaces a named form factory.
publicvoidsetElement(string $type,mixed $factory)Registers or replaces an element type factory.
protectedarraygetDefaultServices()Returns the built-in element type factories.
Methods
__construct()
public function __construct( array $definitions = [] );get()
public function get(
string $name,
mixed $entity = null
): Form;Returns the named form.
Without an entity the result is lazily created and cached. With an entity a fresh form is always produced.
getElement()
public function getElement( string $type );Returns the factory callable for the given element type.
has()
public function has( string $name ): bool;Checks whether a named form factory is registered.
hasElement()
public function hasElement( string $type ): bool;Checks whether an element type is registered.
set()
public function set(
string $name,
mixed $factory
): void;Registers or replaces a named form factory.
The callable must accept one argument (?object $entity) and return a Form instance. Replacing a registration clears any cached instance so the next get() call rebuilds from the new factory.
setElement()
public function setElement(
string $type,
mixed $factory
): void;Registers or replaces an element type factory.
The callable must accept (string $name, array $options, array $attributes) and return an ElementInterface instance.
getDefaultServices()
protected function getDefaultServices(): array;Returns the built-in element type factories.
Each value is a callable: fn(string $name, array $options, array $attributes): ElementInterface
Forms\Loader\ArrayLoader
ClassSource on GitHubSupplies form element definitions from a PHP array.
Phalcon\Forms\Loader\ArrayLoader- implementsPhalcon\Contracts\Forms\Schema
Uses Phalcon\Contracts\Forms\Schema · Phalcon\Forms\Exception · Phalcon\Forms\Exceptions\SchemaEntryMissingKey · Phalcon\Forms\Exceptions\SchemaEntryNotArray
Method Summary
public__construct(array $definitions)publicarrayload()protectedvoidvalidateDefinition(mixed $definition,int $index)Properties
protectedarray$definitionsMethods
__construct()
public function __construct( array $definitions );load()
public function load(): array;validateDefinition()
protected function validateDefinition(
mixed $definition,
int $index
): void;Forms\Loader\JsonLoader
ClassSource on GitHubSupplies form element definitions from a JSON string or file.
When $source looks like an existing, readable file path it is read from disk first; otherwise the value is treated as a raw JSON string.
Phalcon\Forms\Loader\JsonLoader- implementsPhalcon\Contracts\Forms\Schema
Uses InvalidArgumentException · Phalcon\Contracts\Forms\Schema · Phalcon\Forms\Exception · Phalcon\Forms\Exceptions\InvalidJsonSchema · Phalcon\Forms\Exceptions\JsonSchemaNotArray · Phalcon\Support\Helper\Json\Decode · Phalcon\Traits\Php\FileTrait
Method Summary
Properties
protectedstring$sourceMethods
__construct()
public function __construct( string $source );load()
public function load(): array;Forms\Loader\YamlLoader
ClassSource on GitHubSupplies form element definitions from a YAML string or file.
Requires the PHP yaml extension (pecl/yaml).
When $source is an existing, readable file path the file is parsed directly; otherwise the value is treated as a raw YAML string.
Phalcon\Forms\Loader\YamlLoader- implementsPhalcon\Contracts\Forms\Schema
Uses Phalcon\Contracts\Forms\Schema · Phalcon\Forms\Exception · Phalcon\Forms\Exceptions\YamlExtensionRequired · Phalcon\Forms\Exceptions\YamlSchemaNotArray · Phalcon\Traits\Php\InfoTrait
Method Summary
Properties
protectedstring$sourceMethods
__construct()
public function __construct( string $source );load()
public function load(): array;Forms\Manager
ClassSource on GitHubForms Manager
Phalcon\Forms\Manager
Uses Phalcon\Contracts\Forms\Schema · Phalcon\Forms\Exceptions\FormNotRegistered · Phalcon\Forms\Form
Method Summary
public__construct(FormsLocator|null $locator = null)Manager constructor.
publicFormcreate(string $name,mixed $entity = null)Creates a form registering it in the forms manager
publicFormget(string $name)Returns a form by its name
publicFormsLocatorgetLocator()Returns the FormsLocator instance.
publicboolhas(string $name)Checks if a form is registered in the forms manager
publicFormloadForm(string $name,Schema $schema,mixed $entity = null)Creates a form from a Schema source, registers it in the manager,
publicstaticset(string $name,Form $form)Registers a form in the Forms Manager
Properties
protectedarray$forms = []protectedFormsLocator$locatorMethods
__construct()
public function __construct( FormsLocator|null $locator = null );Manager constructor.
create()
public function create(
string $name,
mixed $entity = null
): Form;Creates a form registering it in the forms manager
get()
public function get( string $name ): Form;Returns a form by its name
getLocator()
public function getLocator(): FormsLocator;Returns the FormsLocator instance.
has()
public function has( string $name ): bool;Checks if a form is registered in the forms manager
loadForm()
public function loadForm(
string $name,
Schema $schema,
mixed $entity = null
): Form;Creates a form from a Schema source, registers it in the manager, and registers a factory in the locator for entity-aware retrieval.
set()
public function set(
string $name,
Form $form
): static;Registers a form in the Forms Manager