Phalcon forms
NOTE
All classes are prefixed with Phalcon
Forms\Element\AbstractElement
¶
-
Namespace
Phalcon\Forms\Element
-
Uses
InvalidArgumentExceptionPhalcon\Di\DiPhalcon\Di\DiInterfacePhalcon\Filter\Validation\ValidatorInterfacePhalcon\Forms\ExceptionPhalcon\Forms\FormPhalcon\Html\TagFactoryPhalcon\Messages\MessageInterfacePhalcon\Messages\Messages
-
Extends
-
Implements
ElementInterface
This is a base class for form elements
Properties¶
/**
* @var array
*/
protected $attributes;
/**
* @var array
*/
protected $filters;
/**
* @var Form|null
*/
protected $form;
/**
* @var string|null
*/
protected $label;
/**
* @var string
*/
protected $method = inputText;
/**
* @var Messages
*/
protected $messages;
/**
* @var string
*/
protected $name;
/**
* @var array
*/
protected $options;
/**
* @var TagFactory|null
*/
protected $tagFactory;
/**
* @var array
*/
protected $validators;
/**
* @var mixed|null
*/
protected $value;
Methods¶
Constructor Magic method __toString renders the widget without attributes Adds a filter to current list of filters Adds a validator to the element Adds a group of validators Appends a message to the internal message list Clears element to its default value Returns the value of an attribute if present Returns the default attributes for the element Returns the default value assigned to the element Returns the element filters Returns the parent form to the element Returns the element label Returns the messages that belongs to the element The element needs to be attached to a form Returns the element name Returns the tagFactory; throws exception if not present Returns the value of an option if present Returns the options for the element Returns the validators registered for the element Returns the element's value Checks whether there are messages attached to the element Generate the HTML to label the element Renders the element widget returning HTML Sets a default attribute for the element Sets default attributes for the element Sets a default value in case the form does not use an entity or there is no value available for the element in _POST Sets the element filters Sets the parent form to the element Sets the element label Sets the validation messages related to the element Sets the element name Sets the TagFactory Sets an option for the element Sets options for the element Returns the tagFactory; throws exception if not presentForms\Element\Check¶
-
Namespace
Phalcon\Forms\Element
-
Uses
-
Extends
AbstractElement -
Implements
Component INPUT[type=check] for forms
Properties¶
/**
* @var string
*/
protected $method = inputCheckbox;
/**
* @var mixed
*/
protected $uncheckedValue;
/**
* @var bool
*/
protected $uncheckedValueSet = false;
Methods¶
Returns the value to bind when the checkbox is absent from submitted data. Only meaningful when hasUncheckedValue() is true. Whether an "unchecked value" has been explicitly registered. 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¶
-
Namespace
Phalcon\Forms\Element
-
Uses
Phalcon\Html\TagFactory
-
Extends
AbstractElement -
Implements
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]]
Properties¶
Methods¶
Constructor Returns the group options Renders the checkbox group returning HTML Sets the group optionsForms\Element\Date¶
-
Namespace
Phalcon\Forms\Element
-
Uses
Phalcon\Tag
-
Extends
AbstractElement -
Implements
Component INPUT[type=date] for forms
Properties¶
Forms\Element\ElementInterface
¶
-
Namespace
Phalcon\Forms\Element
-
Uses
Phalcon\Filter\Validation\ValidatorInterfacePhalcon\Forms\FormPhalcon\Messages\MessageInterfacePhalcon\Messages\Messages
-
Extends
-
Implements
Interface for Phalcon\Forms\Element classes
Methods¶
Adds a filter to current list of filters Adds a validator to the element Adds a group of validators Appends a message to the internal message list Clears every element in the form to its default value Returns the value of an attribute if present Returns the default attributes for the element Returns the default value assigned to the element Returns the element's filters Returns the parent form to the element Returns the element's label Returns the messages that belongs to the element The element needs to be attached to a form Returns the element's name Returns the value of an option if present Returns the options for the element Returns the validators registered for the element Returns the element's value Checks whether there are messages attached to the element Generate the HTML to label the element Renders the element widget Sets a default attribute for the element Sets default attributes for the element Sets a default value in case the form does not use an entity or there is no value available for the element in _POST Sets the element's filters Sets the parent form to the element Sets the element label Sets the validation messages related to the element Sets the element's name Sets an option for the element Sets options for the elementForms\Element\Email¶
-
Namespace
Phalcon\Forms\Element
-
Uses
Phalcon\Tag
-
Extends
AbstractElement -
Implements
Component INPUT[type=email] for forms
Properties¶
Forms\Element\File¶
-
Namespace
Phalcon\Forms\Element
-
Uses
Phalcon\Tag
-
Extends
AbstractElement -
Implements
Component INPUT[type=file] for forms
Properties¶
Forms\Element\Hidden¶
-
Namespace
Phalcon\Forms\Element
-
Uses
Phalcon\Tag
-
Extends
AbstractElement -
Implements
Component INPUT[type=hidden] for forms
Properties¶
Forms\Element\Numeric¶
-
Namespace
Phalcon\Forms\Element
-
Uses
Phalcon\Tag
-
Extends
AbstractElement -
Implements
Component INPUT[type=number] for forms
Properties¶
Forms\Element\Password¶
-
Namespace
Phalcon\Forms\Element
-
Uses
Phalcon\Tag
-
Extends
AbstractElement -
Implements
Component INPUT[type=password] for forms
Properties¶
Forms\Element\Radio¶
-
Namespace
Phalcon\Forms\Element
-
Uses
Phalcon\Tag
-
Extends
AbstractElement -
Implements
Component INPUT[type=radio] for forms
Properties¶
Forms\Element\RadioGroup¶
-
Namespace
Phalcon\Forms\Element
-
Uses
Phalcon\Html\TagFactory
-
Extends
AbstractElement -
Implements
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]]
Properties¶
Methods¶
Constructor Returns the group options Renders the radio group returning HTML Sets the group optionsForms\Element\Select¶
-
Namespace
Phalcon\Forms\Element
-
Uses
Phalcon\Tag\Select
-
Extends
AbstractElement -
Implements
Component SELECT (choice) for forms
Properties¶
Methods¶
Constructor Adds an option to the current options Returns the choices' options Renders the element widget returning HTML Set the choice's options Returns an array of prepared attributes for Phalcon\Html\TagFactory helpers according to the element parametersForms\Element\Submit¶
-
Namespace
Phalcon\Forms\Element
-
Uses
Phalcon\Tag
-
Extends
AbstractElement -
Implements
Component INPUT[type=submit] for forms
Properties¶
Forms\Element\Text¶
-
Namespace
Phalcon\Forms\Element
-
Uses
Phalcon\Forms\Exception
-
Extends
AbstractElement -
Implements
Component INPUT[type=text] for forms
Forms\Element\TextArea¶
-
Namespace
Phalcon\Forms\Element
-
Uses
Phalcon\Tag
-
Extends
AbstractElement -
Implements
Component TEXTAREA for forms
Properties¶
Forms\Exception¶
-
Namespace
Phalcon\Forms
-
Uses
-
Extends
\Exception -
Implements
Exceptions thrown in Phalcon\Forms will use this class
Methods¶
Forms\Form¶
-
Namespace
Phalcon\Forms
-
Uses
CountableIteratorPhalcon\Contracts\Forms\SchemaPhalcon\Di\DiInterfacePhalcon\Di\InjectablePhalcon\Filter\FilterInterfacePhalcon\Filter\ValidationPhalcon\Filter\Validation\ValidationInterfacePhalcon\Forms\Element\CheckPhalcon\Forms\Element\ElementInterfacePhalcon\Html\AttributesPhalcon\Html\Attributes\AttributesInterfacePhalcon\Html\TagFactoryPhalcon\Messages\MessagesPhalcon\Support\SettingsPhalcon\Tag
-
Extends
Injectable -
Implements
AttributesInterfaceCountableIterator
This component allows to build forms using an object-oriented interface
Properties¶
/**
* @var AttributesInterface|null
*/
protected $attributes;
/**
* @var array
*/
protected $data;
/**
* @var array
*/
protected $filteredData;
/**
* @var array
*/
protected $elements;
/**
* @var array
*/
protected $elementsIndexed;
/**
* @var object|null
*/
protected $entity;
/**
* @var Messages|array|null
*/
protected $messages;
/**
* @var int
*/
protected $position = ;
/**
* @var array
*/
protected $options;
/**
* @var TagFactory|null
*/
protected $tagFactory;
/**
* @var ValidationInterface|null
*/
protected $validation;
/**
* @var array
*/
protected $whitelist;
Methods¶
Phalcon\Forms\Form constructor Adds an element to the form Binds data to the entity Clears every element in the form to its default value Returns the number of elements in the form Returns the current element in the iterator Returns an element added to the form by its name Returns the form's action Get Form attributes collection Returns the form elements added to the form Returns the entity related to the model Gets a value from the internal filtered data or calls getValue(name) Returns a label for an element Returns the messages generated in the validation.if ($form->isValid($_POST) == false) {
$messages = $form->getMessages();
foreach ($messages as $message) {
echo $message, "<br>";
}
}
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().
Moves the internal iteration pointer to the next position Removes an element from the form Renders a specific item in the form Rewinds the internal iterator Sets the form's action Set form attributes collection Sets the entity related to the model Sets the tagFactory for the form Sets an option for the form Sets options for the element Sets the default validation Sets the default whitelist Check if the current element in the iterator is validForms\FormsLocator¶
-
Namespace
Phalcon\Forms
-
Uses
Phalcon\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
-
Extends
-
Implements
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().
Properties¶
/**
* Element type → factory callable.
*
* @var array
*/
private $elements;
/**
* Form name → factory callable.
*
* @var array
*/
private $factories;
/**
* Cached entity-less form instances.
*
* @var array
*/
private $instances;
Methods¶
Returns the named form.Without an entity the result is lazily created and cached. With an entity a fresh form is always produced.
Returns the factory callable for the given element type. Checks whether a named form factory is registered. Checks whether an element type is registered. 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.
Registers or replaces an element type factory.The callable must accept (string $name, array $options, array $attributes) and return an ElementInterface instance.
Returns the built-in element type factories.Each value is a callable: fn(string $name, array $options, array $attributes): ElementInterface
Forms\Loader\ArrayLoader¶
-
Namespace
Phalcon\Forms\Loader
-
Uses
Phalcon\Contracts\Forms\SchemaPhalcon\Forms\Exception
-
Extends
-
Implements
Schema
Supplies form element definitions from a PHP array.
Properties¶
Methods¶
Forms\Loader\JsonLoader¶
-
Namespace
Phalcon\Forms\Loader
-
Uses
InvalidArgumentExceptionPhalcon\Contracts\Forms\SchemaPhalcon\Forms\ExceptionPhalcon\Support\Helper\Json\Decode
-
Extends
-
Implements
Schema
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.
Properties¶
Methods¶
Forms\Loader\YamlLoader¶
-
Namespace
Phalcon\Forms\Loader
-
Uses
Phalcon\Contracts\Forms\SchemaPhalcon\Forms\Exception
-
Extends
-
Implements
Schema
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.
Properties¶
Methods¶
Forms\Manager¶
-
Namespace
Phalcon\Forms
-
Uses
Phalcon\Contracts\Forms\SchemaPhalcon\Forms\Form
-
Extends
-
Implements
Forms Manager