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 InvalidArgumentException · 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
Method Summary
public__construct(string$name,array$attributes = [])Constructorpublicstring__toString()Magic method __toString renders the widget without attributespublicElementInterfaceaddFilter( string$filter )Adds a filter to current list of filterspublicElementInterfaceaddValidator( ValidatorInterface$validator )Adds a validator to the elementpublicElementInterfaceaddValidators(array$validators,bool$merge = true)Adds a group of validatorspublicElementInterfaceappendMessage( MessageInterface$message )Appends a message to the internal message listpublicElementInterfaceclear()Clears element to its default valuepublicmixedgetAttribute(string$attribute,mixed$defaultValue = null)Returns the value of an attribute if presentpublicarraygetAttributes()Returns the default attributes for the elementpublicmixedgetDefault()Returns the default value assigned to the elementpublicgetFilters()Returns the element filterspublicFormgetForm()Returns the parent form to the elementpublicstring|nullgetLabel()Returns the element labelpublicMessagesgetMessages()Returns the messages that belongs to the elementpublicstringgetName()Returns the element namepublicTagFactory|nullgetTagFactory()Returns the tagFactory; throws exception if not presentpublicmixedgetUserOption(string$option,mixed$defaultValue = null)Returns the value of an option if presentpublicarraygetUserOptions()Returns the options for the elementpublicValidatorInterface[]getValidators()Returns the validators registered for the elementpublicmixedgetValue()Returns the element's valuepublicboolhasMessages()Checks whether there are messages attached to the elementpublicstringlabel( array$attributes = [] )Generate the HTML to label the elementpublicstringrender( array$attributes = [] )Renders the element widget returning HTMLpublicElementInterfacesetAttribute(string$attribute,mixed$value)Sets a default attribute for the elementpublicElementInterfacesetAttributes( array$attributes )Sets default attributes for the elementpublicElementInterfacesetDefault( mixed$value )Sets a default value in case the form does not use an entitypublicElementInterfacesetFilters( mixed$filters )Sets the element filterspublicElementInterfacesetForm( Form$form )Sets the parent form to the elementpublicElementInterfacesetLabel( string$label )Sets the element labelpublicElementInterfacesetMessages( Messages$messages )Sets the validation messages related to the elementpublicElementInterfacesetName( string$name )Sets the element namepublicstaticsetTagFactory( TagFactory$tagFactory )Sets the TagFactorypublicElementInterfacesetUserOption(string$option,mixed$value)Sets an option for the elementpublicElementInterfacesetUserOptions( array$options )Sets options for the elementprotectedTagFactorygetLocalTagFactory()Returns the tagFactory; throws exception if not presentProperties
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 submittedpublicboolhasUncheckedValue()Whether an "unchecked value" has been explicitly registered.publicstaticsetUncheckedValue( mixed$value )Registers a value to bind when the checkbox is absent from submittedProperties
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\Html\TagFactory
Method Summary
public__construct(string$name,array$options = [],array$attributes = [])ConstructorpublicarraygetOptions()Returns the group optionspublicstringrender( array$attributes = [] )Renders the checkbox group returning HTMLpublicElementInterfacesetOptions( array$options )Sets the group optionsProperties
protectedarray$options = []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
Uses Phalcon\Tag
Properties
protectedstring$method = "inputDate"Forms\Element\ElementInterface
InterfaceSource on GitHubInterface for Phalcon\Forms\Element classes
Phalcon\Forms\Element\ElementInterface
Uses 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 filterspublicElementInterfaceaddValidator( ValidatorInterface$validator )Adds a validator to the elementpublicElementInterfaceaddValidators(array$validators,bool$merge = true)Adds a group of validatorspublicElementInterfaceappendMessage( MessageInterface$message )Appends a message to the internal message listpublicElementInterfaceclear()Clears every element in the form to its default valuepublicmixedgetAttribute(string$attribute,mixed$defaultValue = null)Returns the value of an attribute if presentpublicarraygetAttributes()Returns the default attributes for the elementpublicmixedgetDefault()Returns the default value assigned to the elementpublicgetFilters()Returns the element's filterspublicFormgetForm()Returns the parent form to the elementpublicstring|nullgetLabel()Returns the element's labelpublicMessagesgetMessages()Returns the messages that belongs to the elementpublicstringgetName()Returns the element's namepublicmixedgetUserOption(string$option,mixed$defaultValue = null)Returns the value of an option if presentpublicarraygetUserOptions()Returns the options for the elementpublicValidatorInterface[]getValidators()Returns the validators registered for the elementpublicmixedgetValue()Returns the element's valuepublicboolhasMessages()Checks whether there are messages attached to the elementpublicstringlabel()Generate the HTML to label the elementpublicstringrender( array$attributes = [] )Renders the element widgetpublicElementInterfacesetAttribute(string$attribute,mixed$value)Sets a default attribute for the elementpublicElementInterfacesetAttributes( array$attributes )Sets default attributes for the elementpublicElementInterfacesetDefault( mixed$value )Sets a default value in case the form does not use an entitypublicElementInterfacesetFilters( mixed$filters )Sets the element's filterspublicElementInterfacesetForm( Form$form )Sets the parent form to the elementpublicElementInterfacesetLabel( string$label )Sets the element labelpublicElementInterfacesetMessages( Messages$messages )Sets the validation messages related to the elementpublicElementInterfacesetName( string$name )Sets the element's namepublicElementInterfacesetUserOption(string$option,mixed$value)Sets an option for the elementpublicElementInterfacesetUserOptions( array$options )Sets options for the elementMethods
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
Uses Phalcon\Tag
Properties
protectedstring$method = "inputEmail"Forms\Element\File
ClassSource on GitHubComponent INPUT[type=file] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\File
Uses Phalcon\Tag
Properties
protectedstring$method = "inputFile"Forms\Element\Hidden
ClassSource on GitHubComponent INPUT[type=hidden] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Hidden
Uses Phalcon\Tag
Properties
protectedstring$method = "inputHidden"Forms\Element\Numeric
ClassSource on GitHubComponent INPUT[type=number] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Numeric
Uses Phalcon\Tag
Properties
protectedstring$method = "inputNumeric"Forms\Element\Password
ClassSource on GitHubComponent INPUT[type=password] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Password
Uses Phalcon\Tag
Properties
protectedstring$method = "inputPassword"Forms\Element\Radio
ClassSource on GitHubComponent INPUT[type=radio] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Radio
Uses Phalcon\Tag
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\Html\TagFactory
Method Summary
public__construct(string$name,array$options = [],array$attributes = [])ConstructorpublicarraygetOptions()Returns the group optionspublicstringrender( array$attributes = [] )Renders the radio group returning HTMLpublicElementInterfacesetOptions( array$options )Sets the group optionsProperties
protectedarray$options = []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\Tag\Select
Method Summary
public__construct(string$name,mixed$options = null,array$attributes = [])ConstructorpublicElementInterfaceaddOption( mixed$option )Adds an option to the current optionspublicgetOptions()Returns the choices' optionspublicstringrender( array$attributes = [] )Renders the element widget returning HTMLpublicElementInterfacesetOptions( mixed$options )Set the choice's optionsprotectedarrayprepareAttributes( array$attributes = [] )Returns an array of prepared attributes for Phalcon\Html\TagFactoryProperties
protectedobject|array|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
Uses Phalcon\Tag
Properties
protectedstring$method = "inputSubmit"Forms\Element\Text
ClassSource on GitHubComponent INPUT[type=text] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Text
Uses Phalcon\Forms\Exception
Forms\Element\TextArea
ClassSource on GitHubComponent TEXTAREA for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\TextArea
Uses Phalcon\Tag
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
\stdClassPhalcon\Di\InjectablePhalcon\Forms\Form- implements\Countable,\Iterator,Phalcon\Html\Attributes\AttributesInterface
Uses Countable · Iterator · Phalcon\Contracts\Forms\Schema · 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 constructorpublicstaticadd(ElementInterface$element,string|null$position = null,bool|null$type = null)Adds an element to the formpublicstaticbind(array$data,mixed$entity = null,array$whitelist = [])Binds data to the entitypublicstaticclear( mixed$fields = null )Clears every element in the form to its default valuepublicintcount()Returns the number of elements in the formpublicmixedcurrent()Returns the current element in the iteratorpublicElementInterfaceget( string$name )Returns an element added to the form by its namepublicstringgetAction()Returns the form's actionpublicAttributesgetAttributes()Get Form attributes collectionpublicElementInterface[]getElements()Returns the form elements added to the formpublicgetEntity()Returns the entity related to the modelpublicmixed|nullgetFilteredValue( string$name )Gets a value from the internal filtered data or calls getValue(name)publicstringgetLabel( string$name )Returns a label for an elementpublicMessagesgetMessages()Returns the messages generated in the validation.publicMessagesgetMessagesFor( string$name )Returns the messages generated for a specific elementpublicTagFactory|nullgetTagFactory()Returns the tagFactory objectpublicmixedgetUserOption(string$option,mixed$defaultValue = null)Returns the value of an option if presentpublicarraygetUserOptions()Returns the options for the elementpublicValidationInterface|nullgetValidation()return ValidationInterface|nullpublicmixed|nullgetValue( string$name )Gets a value from the internal related entity or from the default valuepublicarraygetWhitelist()return arraypublicboolhas( string$name )Check if the form contains an elementpublicboolhasMessagesFor( string$name )Check if messages were generated for a specific elementpublicboolisValid(mixed$data = null,mixed$entity = null,array$whitelist = [])Validates the formpublicintkey()Returns the current position/key in the iteratorpublicstringlabel(string$name,array$attributes = [])Generate the label of an element added to the form including HTMLpublicstaticload(Schema$schema,FormsLocator$locator)Loads elements into the form from a Schema source.publicvoidnext()Moves the internal iteration pointer to the next positionpublicboolremove( string$name )Removes an element from the formpublicstringrender(string$name,array$attributes = [])Renders a specific item in the formpublicvoidrewind()Rewinds the internal iteratorpublicstaticsetAction( string$action )Sets the form's actionpublicstaticsetAttributes( Attributes$attributes )Set form attributes collectionpublicstaticsetEntity( mixed$entity )Sets the entity related to the modelpublicstaticsetTagFactory( TagFactory$tagFactory )Sets the tagFactory for the formpublicstaticsetUserOption(string$option,mixed$value)Sets an option for the formpublicstaticsetUserOptions( array$options )Sets options for the elementpublicstaticsetValidation( ValidationInterface$validation )Sets the default validationpublicstaticsetWhitelist( array$whitelist )Sets the default whitelistpublicboolvalid()Check if the current element in the iterator is validProperties
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;return 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\Forms\Element\Check · Phalcon\Forms\Element\CheckGroup · Phalcon\Forms\Element\Date · 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 managerpublicFormget( string$name )Returns a form by its namepublicFormsLocatorgetLocator()Returns the FormsLocator instance.publicboolhas( string$name )Checks if a form is registered in the forms managerpublicFormloadForm(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 ManagerProperties
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