Phalcon forms
NOTE
All classes are prefixed with Phalcon
Forms\Element\AbstractElement¶
Abstract Source on GitHub
This 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 = []) Constructor public string __toString() Magic method __toString renders the widget without attributes public ElementInterface addFilter( string $filter ) Adds a filter to current list of filters public ElementInterface addValidator( ValidatorInterface $validator ) Adds a validator to the element public ElementInterface addValidators(array $validators,bool $merge = true) Adds a group of validators public ElementInterface appendMessage( MessageInterface $message ) Appends a message to the internal message list public ElementInterface clear() Clears element to its default value public mixed getAttribute(string $attribute,mixed $defaultValue = null) Returns the value of an attribute if present public array getAttributes() Returns the default attributes for the element public mixed getDefault() Returns the default value assigned to the element public getFilters() Returns the element filters public Form getForm() Returns the parent form to the element public string|null getLabel() Returns the element label public Messages getMessages() Returns the messages that belongs to the element public string getName() Returns the element name public TagFactory|null getTagFactory() Returns the tagFactory; throws exception if not present public mixed getUserOption(string $option,mixed $defaultValue = null) Returns the value of an option if present public array getUserOptions() Returns the options for the element public ValidatorInterface[] getValidators() Returns the validators registered for the element public mixed getValue() Returns the element's value public bool hasMessages() Checks whether there are messages attached to the element public string label( array $attributes = [] ) Generate the HTML to label the element public string render( array $attributes = [] ) Renders the element widget returning HTML public ElementInterface setAttribute(string $attribute,mixed $value) Sets a default attribute for the element public ElementInterface setAttributes( array $attributes ) Sets default attributes for the element public ElementInterface setDefault( mixed $value ) Sets a default value in case the form does not use an entity public ElementInterface setFilters( mixed $filters ) Sets the element filters public ElementInterface setForm( Form $form ) Sets the parent form to the element public ElementInterface setLabel( string $label ) Sets the element label public ElementInterface setMessages( Messages $messages ) Sets the validation messages related to the element public ElementInterface setName( string $name ) Sets the element name public static setTagFactory( TagFactory $tagFactory ) Sets the TagFactory public ElementInterface setUserOption(string $option,mixed $value) Sets an option for the element public ElementInterface setUserOptions( array $options ) Sets options for the element protected TagFactory getLocalTagFactory() Returns the tagFactory; throws exception if not present Properties¶
protected array $attributes = [] protected array $filters = [] protected Form|null $form = null protected string|null $label = null protected Messages $messages protected string $method = "inputText" protected string $name protected array $options = [] protected TagFactory|null $tagFactory = null protected array $validators = [] protected mixed|null $value = null Methods¶
__construct()¶
Constructor
__toString()¶
Magic method __toString renders the widget without attributes
addFilter()¶
Adds a filter to current list of filters
addValidator()¶
Adds a validator to the element
addValidators()¶
Adds a group of validators
appendMessage()¶
Appends a message to the internal message list
clear()¶
Clears element to its default value
getAttribute()¶
Returns the value of an attribute if present
getAttributes()¶
Returns the default attributes for the element
getDefault()¶
Returns the default value assigned to the element
getFilters()¶
Returns the element filters
getForm()¶
Returns the parent form to the element
getLabel()¶
Returns the element label
getMessages()¶
Returns the messages that belongs to the element The element needs to be attached to a form
getName()¶
Returns the element name
getTagFactory()¶
Returns the tagFactory; throws exception if not present
getUserOption()¶
Returns the value of an option if present
getUserOptions()¶
Returns the options for the element
getValidators()¶
Returns the validators registered for the element
getValue()¶
Returns the element's value
hasMessages()¶
Checks whether there are messages attached to the element
label()¶
Generate the HTML to label the element
render()¶
Renders the element widget returning HTML
setAttribute()¶
Sets a default attribute for the element
setAttributes()¶
Sets default attributes for the element
setDefault()¶
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()¶
Sets the element filters
setForm()¶
Sets the parent form to the element
setLabel()¶
Sets the element label
setMessages()¶
Sets the validation messages related to the element
setName()¶
Sets the element name
setTagFactory()¶
Sets the TagFactory
setUserOption()¶
Sets an option for the element
setUserOptions()¶
Sets options for the element
getLocalTagFactory()¶
Returns the tagFactory; throws exception if not present
Forms\Element\Check¶
Class Source on GitHub
Component INPUT[type=check] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Check
Method Summary¶
public mixed getUncheckedValue() Returns the value to bind when the checkbox is absent from submitted public bool hasUncheckedValue() Whether an "unchecked value" has been explicitly registered. public static setUncheckedValue( mixed $value ) Registers a value to bind when the checkbox is absent from submitted Properties¶
protected string $method = "inputCheckbox" protected mixed $uncheckedValue = null protected bool $uncheckedValueSet = false Methods¶
getUncheckedValue()¶
Returns the value to bind when the checkbox is absent from submitted data. Only meaningful when hasUncheckedValue() is true.
hasUncheckedValue()¶
Whether an "unchecked value" has been explicitly registered.
setUncheckedValue()¶
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¶
Class Source on GitHub
Component 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 = []) Constructor public array getOptions() Returns the group options public string render( array $attributes = [] ) Renders the checkbox group returning HTML public ElementInterface setOptions( array $options ) Sets the group options Properties¶
protected array $options = [] Methods¶
__construct()¶
Constructor
getOptions()¶
Returns the group options
render()¶
Renders the checkbox group returning HTML
setOptions()¶
Sets the group options
Forms\Element\Date¶
Class Source on GitHub
Component INPUT[type=date] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Date
Uses Phalcon\Tag
Properties¶
protected string $method = "inputDate" Forms\Element\ElementInterface¶
Interface Source on GitHub
Interface 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¶
public ElementInterface addFilter( string $filter ) Adds a filter to current list of filters public ElementInterface addValidator( ValidatorInterface $validator ) Adds a validator to the element public ElementInterface addValidators(array $validators,bool $merge = true) Adds a group of validators public ElementInterface appendMessage( MessageInterface $message ) Appends a message to the internal message list public ElementInterface clear() Clears every element in the form to its default value public mixed getAttribute(string $attribute,mixed $defaultValue = null) Returns the value of an attribute if present public array getAttributes() Returns the default attributes for the element public mixed getDefault() Returns the default value assigned to the element public getFilters() Returns the element's filters public Form getForm() Returns the parent form to the element public string|null getLabel() Returns the element's label public Messages getMessages() Returns the messages that belongs to the element public string getName() Returns the element's name public mixed getUserOption(string $option,mixed $defaultValue = null) Returns the value of an option if present public array getUserOptions() Returns the options for the element public ValidatorInterface[] getValidators() Returns the validators registered for the element public mixed getValue() Returns the element's value public bool hasMessages() Checks whether there are messages attached to the element public string label() Generate the HTML to label the element public string render( array $attributes = [] ) Renders the element widget public ElementInterface setAttribute(string $attribute,mixed $value) Sets a default attribute for the element public ElementInterface setAttributes( array $attributes ) Sets default attributes for the element public ElementInterface setDefault( mixed $value ) Sets a default value in case the form does not use an entity public ElementInterface setFilters( mixed $filters ) Sets the element's filters public ElementInterface setForm( Form $form ) Sets the parent form to the element public ElementInterface setLabel( string $label ) Sets the element label public ElementInterface setMessages( Messages $messages ) Sets the validation messages related to the element public ElementInterface setName( string $name ) Sets the element's name public ElementInterface setUserOption(string $option,mixed $value) Sets an option for the element public ElementInterface setUserOptions( array $options ) Sets options for the element Methods¶
addFilter()¶
Adds a filter to current list of filters
addValidator()¶
Adds a validator to the element
addValidators()¶
Adds a group of validators
appendMessage()¶
Appends a message to the internal message list
clear()¶
Clears every element in the form to its default value
getAttribute()¶
Returns the value of an attribute if present
getAttributes()¶
Returns the default attributes for the element
getDefault()¶
Returns the default value assigned to the element
getFilters()¶
Returns the element's filters
getForm()¶
Returns the parent form to the element
getLabel()¶
Returns the element's label
getMessages()¶
Returns the messages that belongs to the element The element needs to be attached to a form
getName()¶
Returns the element's name
getUserOption()¶
Returns the value of an option if present
getUserOptions()¶
Returns the options for the element
getValidators()¶
Returns the validators registered for the element
getValue()¶
Returns the element's value
hasMessages()¶
Checks whether there are messages attached to the element
label()¶
Generate the HTML to label the element
render()¶
Renders the element widget
setAttribute()¶
Sets a default attribute for the element
setAttributes()¶
Sets default attributes for the element
setDefault()¶
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()¶
Sets the element's filters
setForm()¶
Sets the parent form to the element
setLabel()¶
Sets the element label
setMessages()¶
Sets the validation messages related to the element
setName()¶
Sets the element's name
setUserOption()¶
Sets an option for the element
setUserOptions()¶
Sets options for the element
Forms\Element\Email¶
Class Source on GitHub
Component INPUT[type=email] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Email
Uses Phalcon\Tag
Properties¶
protected string $method = "inputEmail" Forms\Element\File¶
Class Source on GitHub
Component INPUT[type=file] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\File
Uses Phalcon\Tag
Properties¶
protected string $method = "inputFile" Forms\Element\Hidden¶
Class Source on GitHub
Component INPUT[type=hidden] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Hidden
Uses Phalcon\Tag
Properties¶
protected string $method = "inputHidden" Forms\Element\Numeric¶
Class Source on GitHub
Component INPUT[type=number] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Numeric
Uses Phalcon\Tag
Properties¶
protected string $method = "inputNumeric" Forms\Element\Password¶
Class Source on GitHub
Component INPUT[type=password] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Password
Uses Phalcon\Tag
Properties¶
protected string $method = "inputPassword" Forms\Element\Radio¶
Class Source on GitHub
Component INPUT[type=radio] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Radio
Uses Phalcon\Tag
Properties¶
protected string $method = "inputRadio" Forms\Element\RadioGroup¶
Class Source on GitHub
Component 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 = []) Constructor public array getOptions() Returns the group options public string render( array $attributes = [] ) Renders the radio group returning HTML public ElementInterface setOptions( array $options ) Sets the group options Properties¶
protected array $options = [] Methods¶
__construct()¶
Constructor
getOptions()¶
Returns the group options
render()¶
Renders the radio group returning HTML
setOptions()¶
Sets the group options
Forms\Element\Select¶
Class Source on GitHub
Component 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 = []) Constructor public ElementInterface addOption( mixed $option ) Adds an option to the current options public getOptions() Returns the choices' options public string render( array $attributes = [] ) Renders the element widget returning HTML public ElementInterface setOptions( mixed $options ) Set the choice's options protected array prepareAttributes( array $attributes = [] ) Returns an array of prepared attributes for Phalcon\Html\TagFactory Properties¶
protected object|array|null $optionsValues = null Methods¶
__construct()¶
Constructor
addOption()¶
Adds an option to the current options
getOptions()¶
Returns the choices' options
render()¶
Renders the element widget returning HTML
setOptions()¶
Set the choice's options
prepareAttributes()¶
Returns an array of prepared attributes for Phalcon\Html\TagFactory helpers according to the element parameters
Forms\Element\Submit¶
Class Source on GitHub
Component INPUT[type=submit] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Submit
Uses Phalcon\Tag
Properties¶
protected string $method = "inputSubmit" Forms\Element\Text¶
Class Source on GitHub
Component INPUT[type=text] for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\Text
Uses Phalcon\Forms\Exception
Forms\Element\TextArea¶
Class Source on GitHub
Component TEXTAREA for forms
Phalcon\Forms\Element\AbstractElementPhalcon\Forms\Element\TextArea
Uses Phalcon\Tag
Properties¶
protected string $method = "inputTextarea" Forms\Exception¶
Class Source on GitHub
Exceptions 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()¶
usingParameterRequired()¶
Forms\Exceptions\ElementNotInForm¶
Class Source on GitHub
\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\ElementNotInForm
Uses Phalcon\Forms\Exception
Method Summary¶
Methods¶
__construct()¶
Forms\Exceptions\FormElementNameRequired¶
Class Source on GitHub
InvalidArgumentExceptionPhalcon\Forms\Exceptions\FormElementNameRequired
Uses InvalidArgumentException
Method Summary¶
Methods¶
__construct()¶
Forms\Exceptions\FormNotInLocator¶
Class Source on GitHub
\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\FormNotInLocator
Uses Phalcon\Forms\Exception
Method Summary¶
Methods¶
__construct()¶
Forms\Exceptions\FormNotRegistered¶
Class Source on GitHub
\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\FormNotRegistered
Uses Phalcon\Forms\Exception
Method Summary¶
Methods¶
__construct()¶
Forms\Exceptions\InvalidEntity¶
Class Source on GitHub
\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\InvalidEntity
Uses Phalcon\Forms\Exception
Method Summary¶
Methods¶
__construct()¶
Forms\Exceptions\InvalidFilterType¶
Class Source on GitHub
\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\InvalidFilterType
Uses Phalcon\Forms\Exception
Method Summary¶
Methods¶
__construct()¶
Forms\Exceptions\InvalidJsonSchema¶
Class Source on GitHub
\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\InvalidJsonSchema
Uses Phalcon\Forms\Exception
Method Summary¶
Methods¶
__construct()¶
Forms\Exceptions\JsonSchemaNotArray¶
Class Source on GitHub
\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\JsonSchemaNotArray
Uses Phalcon\Forms\Exception
Method Summary¶
Methods¶
__construct()¶
Forms\Exceptions\NoFormElements¶
Class Source on GitHub
\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\NoFormElements
Uses Phalcon\Forms\Exception
Method Summary¶
Methods¶
__construct()¶
Forms\Exceptions\SchemaEntryMissingKey¶
Class Source on GitHub
\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\SchemaEntryMissingKey
Uses Phalcon\Forms\Exception
Method Summary¶
Methods¶
__construct()¶
Forms\Exceptions\SchemaEntryNotArray¶
Class Source on GitHub
\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\SchemaEntryNotArray
Uses Phalcon\Forms\Exception
Method Summary¶
Methods¶
__construct()¶
Forms\Exceptions\UnknownFormElementType¶
Class Source on GitHub
\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\UnknownFormElementType
Uses Phalcon\Forms\Exception
Method Summary¶
Methods¶
__construct()¶
Forms\Exceptions\YamlExtensionRequired¶
Class Source on GitHub
\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\YamlExtensionRequired
Uses Phalcon\Forms\Exception
Method Summary¶
Methods¶
__construct()¶
Forms\Exceptions\YamlSchemaNotArray¶
Class Source on GitHub
\ExceptionPhalcon\Forms\ExceptionPhalcon\Forms\Exceptions\YamlSchemaNotArray
Uses Phalcon\Forms\Exception
Method Summary¶
Methods¶
__construct()¶
Forms\Form¶
Class Source on GitHub
This component allows to build forms using an object-oriented interface
stdClassPhalcon\Di\InjectablePhalcon\Forms\Form— implementsCountable,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 constructor public static add(ElementInterface $element,string $position = null,bool $type = null) Adds an element to the form public static bind(array $data,mixed $entity = null,array $whitelist = []) Binds data to the entity public static clear( mixed $fields = null ) Clears every element in the form to its default value public int count() Returns the number of elements in the form public mixed current() Returns the current element in the iterator public ElementInterface get( string $name ) Returns an element added to the form by its name public string getAction() Returns the form's action public Attributes getAttributes() Get Form attributes collection public ElementInterface[] getElements() Returns the form elements added to the form public getEntity() Returns the entity related to the model public mixed|null getFilteredValue( string $name ) Gets a value from the internal filtered data or calls getValue(name) public string getLabel( string $name ) Returns a label for an element public Messages getMessages() Returns the messages generated in the validation. public Messages getMessagesFor( string $name ) Returns the messages generated for a specific element public TagFactory|null getTagFactory() Returns the tagFactory object public mixed getUserOption(string $option,mixed $defaultValue = null) Returns the value of an option if present public array getUserOptions() Returns the options for the element public ValidationInterface|null getValidation() return ValidationInterface|null public mixed|null getValue( string $name ) Gets a value from the internal related entity or from the default value public array getWhitelist() return array public bool has( string $name ) Check if the form contains an element public bool hasMessagesFor( string $name ) Check if messages were generated for a specific element public bool isValid(mixed $data = null,mixed $entity = null,array $whitelist = []) Validates the form public int key() Returns the current position/key in the iterator public string label(string $name,array $attributes = []) Generate the label of an element added to the form including HTML public static load(Schema $schema,FormsLocator $locator) Loads elements into the form from a Schema source. public void next() Moves the internal iteration pointer to the next position public bool remove( string $name ) Removes an element from the form public string render(string $name,array $attributes = []) Renders a specific item in the form public void rewind() Rewinds the internal iterator public static setAction( string $action ) Sets the form's action public static setAttributes( Attributes $attributes ) Set form attributes collection public static setEntity( mixed $entity ) Sets the entity related to the model public static setTagFactory( TagFactory $tagFactory ) Sets the tagFactory for the form public static setUserOption(string $option,mixed $value) Sets an option for the form public static setUserOptions( array $options ) Sets options for the element public static setValidation( ValidationInterface $validation ) Sets the default validation public static setWhitelist( array $whitelist ) Sets the default whitelist public bool valid() Check if the current element in the iterator is valid Properties¶
protected AttributesInterface|null $attributes = null protected array $data = [] protected array $elements = [] protected array $elementsIndexed = [] protected object|null $entity = null protected array $filteredData = [] protected Messages $messages protected array $options = [] protected int $position = 0 protected TagFactory|null $tagFactory = null protected ValidationInterface|null $validation = null protected array $whitelist = [] Methods¶
__construct()¶
Phalcon\Forms\Form constructor
add()¶
public function add(
ElementInterface $element,
string $position = null,
bool $type = null
): static;
Adds an element to the form
bind()¶
Binds data to the entity
clear()¶
Clears every element in the form to its default value
count()¶
Returns the number of elements in the form
current()¶
Returns the current element in the iterator
get()¶
Returns an element added to the form by its name
getAction()¶
Returns the form's action
getAttributes()¶
Get Form attributes collection
getElements()¶
Returns the form elements added to the form
getEntity()¶
Returns the entity related to the model
getFilteredValue()¶
Gets a value from the internal filtered data or calls getValue(name)
getLabel()¶
Returns a label for an element
getMessages()¶
Returns the messages generated in the validation.
if ($form->isValid($_POST) == false) {
$messages = $form->getMessages();
foreach ($messages as $message) {
echo $message, "<br>";
}
}
getMessagesFor()¶
Returns the messages generated for a specific element
getTagFactory()¶
Returns the tagFactory object
getUserOption()¶
Returns the value of an option if present
getUserOptions()¶
Returns the options for the element
getValidation()¶
return ValidationInterface|null
getValue()¶
Gets a value from the internal related entity or from the default value
getWhitelist()¶
return array
has()¶
Check if the form contains an element
hasMessagesFor()¶
Check if messages were generated for a specific element
isValid()¶
Validates the form
key()¶
Returns the current position/key in the iterator
label()¶
Generate the label of an element added to the form including HTML
load()¶
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()¶
Moves the internal iteration pointer to the next position
remove()¶
Removes an element from the form
render()¶
Renders a specific item in the form
rewind()¶
Rewinds the internal iterator
setAction()¶
Sets the form's action
setAttributes()¶
Set form attributes collection
setEntity()¶
Sets the entity related to the model
setTagFactory()¶
Sets the tagFactory for the form
setUserOption()¶
Sets an option for the form
setUserOptions()¶
Sets options for the element
setValidation()¶
Sets the default validation
setWhitelist()¶
Sets the default whitelist
valid()¶
Check if the current element in the iterator is valid
Forms\FormsLocator¶
Class Source on GitHub
A 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 = [] ) public Form get(string $name,mixed $entity = null) Returns the named form. public getElement( string $type ) Returns the factory callable for the given element type. public bool has( string $name ) Checks whether a named form factory is registered. public bool hasElement( string $type ) Checks whether an element type is registered. public void set(string $name,mixed $factory) Registers or replaces a named form factory. public void setElement(string $type,mixed $factory) Registers or replaces an element type factory. protected array getDefaultServices() Returns the built-in element type factories. Methods¶
__construct()¶
get()¶
Returns the named form.
Without an entity the result is lazily created and cached. With an entity a fresh form is always produced.
getElement()¶
Returns the factory callable for the given element type.
has()¶
Checks whether a named form factory is registered.
hasElement()¶
Checks whether an element type is registered.
set()¶
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()¶
Registers or replaces an element type factory.
The callable must accept (string $name, array $options, array $attributes) and return an ElementInterface instance.
getDefaultServices()¶
Returns the built-in element type factories.
Each value is a callable: fn(string $name, array $options, array $attributes): ElementInterface
Forms\Loader\ArrayLoader¶
Class Source on GitHub
Supplies 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 ) public array load() protected void validateDefinition(mixed $definition,int $index) Properties¶
protected array $definitions Methods¶
__construct()¶
load()¶
validateDefinition()¶
Forms\Loader\JsonLoader¶
Class Source on GitHub
Supplies 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
Method Summary¶
public __construct( string $source ) public array load() protected phpFileGetContents( string $filename ) Properties¶
protected string $source Methods¶
__construct()¶
load()¶
phpFileGetContents()¶
Forms\Loader\YamlLoader¶
Class Source on GitHub
Supplies 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
Method Summary¶
Properties¶
protected string $source Methods¶
__construct()¶
load()¶
Forms\Manager¶
Class Source on GitHub
Forms Manager
Phalcon\Forms\Manager
Uses Phalcon\Contracts\Forms\Schema · Phalcon\Forms\Exceptions\FormNotRegistered · Phalcon\Forms\Form
Method Summary¶
public __construct( FormsLocator $locator = null ) Manager constructor. public Form create(string $name,mixed $entity = null) Creates a form registering it in the forms manager public Form get( string $name ) Returns a form by its name public FormsLocator getLocator() Returns the FormsLocator instance. public bool has( string $name ) Checks if a form is registered in the forms manager public Form loadForm(string $name,Schema $schema,mixed $entity = null) Creates a form from a Schema source, registers it in the manager, public static set(string $name,Form $form) Registers a form in the Forms Manager Properties¶
protected array $forms = [] protected FormsLocator $locator Methods¶
__construct()¶
Manager constructor.
create()¶
Creates a form registering it in the forms manager
get()¶
Returns a form by its name
getLocator()¶
Returns the FormsLocator instance.
has()¶
Checks if a form is registered in the forms manager
loadForm()¶
Creates a form from a Schema source, registers it in the manager, and registers a factory in the locator for entity-aware retrieval.
set()¶
Registers a form in the Forms Manager