Sections

Abstract Class Phalcon\Forms\Element\AbstractElement

GitHub上のソース

Namespace Phalcon\Forms\Element   Uses InvalidArgumentException, Phalcon\Forms\Form, Phalcon\Forms\Exception, Phalcon\Messages\MessageInterface, Phalcon\Messages\Messages, Phalcon\Tag, Phalcon\Validation\ValidatorInterface   Implements ElementInterface

This is a base class for form elements

Properties

//
protected attributes;

//
protected filters;

//
protected form;

//
protected label;

//
protected messages;

//
protected name;

//
protected options;

/**
 * @var array
 */
protected validators;

//
protected value;

メソッド

public function __construct( string $name, array $attributes = [] ): void;

Phalcon\Forms\Element constructor

@param string name Attribute name (value of ‘name’ attribute of HTML element) @param array attributes Additional HTML element attributes

public function __toString(): string;

Magic method __toString renders the widget without attributes

public function addFilter( string $filter ): ElementInterface;

Adds a filter to current list of filters

public function addValidator( ValidatorInterface $validator ): ElementInterface;

Adds a validator to the element

public function addValidators( array $validators, bool $merge = bool ): ElementInterface;

Adds a group of validators

@param \Phalcon\Validation\ValidatorInterface[] validators

public function appendMessage( MessageInterface $message ): ElementInterface;

Appends a message to the internal message list

public function clear(): ElementInterface;

Clears element to its default value

public function getAttribute( string $attribute, mixed $defaultValue = null ): mixed;

Returns the value of an attribute if present

public function getAttributes(): array;

Returns the default attributes for the element

public function getDefault(): mixed;

Returns the default value assigned to the element

public function getFilters();

Returns the element filters

@return mixed

public function getForm(): Form;

Returns the parent form to the element

public function getLabel(): string;

Returns the element label

public function getMessages(): Messages;

Returns the messages that belongs to the element The element needs to be attached to a form

public function getName(): string;

Returns the element name

public function getUserOption( string $option, mixed $defaultValue = null ): mixed;

Returns the value of an option if present

public function getUserOptions(): array;

Returns the options for the element

public function getValidators(): ValidatorInterface[];

Returns the validators registered for the element

public function getValue(): mixed;

Returns the element’s value

public function hasMessages(): bool;

Checks whether there are messages attached to the element

public function label( array $attributes = [] ): string;

Generate the HTML to label the element

public function prepareAttributes( array $attributes = [], bool $useChecked = bool ): array;

Returns an array of prepared attributes for Phalcon\Tag helpers according to the element parameters

public function setAttribute( string $attribute, mixed $value ): ElementInterface;

Sets a default attribute for the element

public function setAttributes( array $attributes ): ElementInterface;

Sets default attributes for the element

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

public function setFilters( mixed $filters ): ElementInterface;

Sets the element filters

@param array string filters
public function setForm( Form $form ): ElementInterface;

Sets the parent form to the element

public function setLabel( string $label ): ElementInterface;

Sets the element label

public function setMessages( Messages $messages ): ElementInterface;

Sets the validation messages related to the element

public function setName( string $name ): ElementInterface;

Sets the element name

public function setUserOption( string $option, mixed $value ): ElementInterface;

Sets an option for the element

public function setUserOptions( array $options ): ElementInterface;

Sets options for the element

Class Phalcon\Forms\Element\Check

GitHub上のソース

Namespace Phalcon\Forms\Element   Uses Phalcon\Tag, Phalcon\Forms\Element\AbstractElement   Extends AbstractElement

Phalcon\Forms\Element\Check

Component INPUT[type=check] for forms

メソッド

public function render( array $attributes = [] ): string;

Renders the element widget returning html

Class Phalcon\Forms\Element\Date

GitHub上のソース

Namespace Phalcon\Forms\Element   Uses Phalcon\Tag, Phalcon\Forms\Element\AbstractElement   Extends AbstractElement

Component INPUT[type=date] for forms

メソッド

public function render( array $attributes = [] ): string;

Renders the element widget returning html

Interface Phalcon\Forms\Element\ElementInterface

GitHub上のソース

Namespace Phalcon\Forms\Element   Uses Phalcon\Forms\Form, Phalcon\Messages\MessageInterface, Phalcon\Messages\Messages, Phalcon\Validation\ValidatorInterface

Interface for Phalcon\Forms\Element classes

メソッド

public function addFilter( string $filter ): ElementInterface;

Adds a filter to current list of filters

public function addValidator( ValidatorInterface $validator ): ElementInterface;

Adds a validator to the element

public function addValidators( array $validators, bool $merge = bool ): ElementInterface;

Adds a group of validators

@param \Phalcon\Validation\ValidatorInterface[]

public function appendMessage( MessageInterface $message ): ElementInterface;

Appends a message to the internal message list

public function clear(): ElementInterface;

Clears every element in the form to its default value

public function getAttribute( string $attribute, mixed $defaultValue = null ): mixed;

Returns the value of an attribute if present

public function getAttributes(): array;

Returns the default attributes for the element

public function getDefault(): mixed;

Returns the default value assigned to the element

public function getFilters();

Returns the element’s filters

@return mixed

public function getForm(): Form;

Returns the parent form to the element

public function getLabel(): string;

Returns the element’s label

public function getMessages(): Messages;

Returns the messages that belongs to the element The element needs to be attached to a form

public function getName(): string;

Returns the element’s name

public function getUserOption( string $option, mixed $defaultValue = null ): mixed;

Returns the value of an option if present

public function getUserOptions(): array;

Returns the options for the element

public function getValidators(): ValidatorInterface[];

Returns the validators registered for the element

public function getValue(): mixed;

Returns the element’s value

public function hasMessages(): bool;

Checks whether there are messages attached to the element

public function label(): string;

Generate the HTML to label the element

public function prepareAttributes( array $attributes = [], bool $useChecked = bool ): array;

Returns an array of prepared attributes for Phalcon\Tag helpers according to the element’s parameters

public function render( array $attributes = [] ): string;

Renders the element widget

public function setAttribute( string $attribute, mixed $value ): ElementInterface;

Sets a default attribute for the element

public function setAttributes( array $attributes ): ElementInterface;

Sets default attributes for the element

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

public function setFilters( mixed $filters ): ElementInterface;

Sets the element’s filters

@param array string filters
public function setForm( Form $form ): ElementInterface;

Sets the parent form to the element

public function setLabel( string $label ): ElementInterface;

Sets the element label

public function setMessages( Messages $messages ): ElementInterface;

Sets the validation messages related to the element

public function setName( string $name ): ElementInterface;

Sets the element’s name

public function setUserOption( string $option, mixed $value ): ElementInterface;

Sets an option for the element

public function setUserOptions( array $options ): ElementInterface;

Sets options for the element

Class Phalcon\Forms\Element\Email

GitHub上のソース

Namespace Phalcon\Forms\Element   Uses Phalcon\Tag, Phalcon\Forms\Element\AbstractElement   Extends AbstractElement

Phalcon\Forms\Element\Email

Component INPUT[type=email] for forms

メソッド

public function render( array $attributes = [] ): string;

Renders the element widget returning html

Class Phalcon\Forms\Element\File

GitHub上のソース

Namespace Phalcon\Forms\Element   Uses Phalcon\Tag, Phalcon\Forms\Element\AbstractElement   Extends AbstractElement

Component INPUT[type=file] for forms

メソッド

public function render( array $attributes = [] ): string;

Renders the element widget returning html

Class Phalcon\Forms\Element\Hidden

GitHub上のソース

Namespace Phalcon\Forms\Element   Uses Phalcon\Tag, Phalcon\Forms\Element\AbstractElement   Extends AbstractElement

Phalcon\Forms\Element\Hidden

Component INPUT[type=hidden] for forms

メソッド

public function render( array $attributes = [] ): string;

Renders the element widget returning html

Class Phalcon\Forms\Element\Numeric

GitHub上のソース

Namespace Phalcon\Forms\Element   Uses Phalcon\Tag, Phalcon\Forms\Element\AbstractElement   Extends AbstractElement

Phalcon\Forms\Element\Numeric

Component INPUT[type=number] for forms

メソッド

public function render( array $attributes = [] ): string;

Renders the element widget returning html

Class Phalcon\Forms\Element\Password

GitHub上のソース

Namespace Phalcon\Forms\Element   Uses Phalcon\Tag, Phalcon\Forms\Element\AbstractElement   Extends AbstractElement

Phalcon\Forms\Element\Password

Component INPUT[type=password] for forms

メソッド

public function render( array $attributes = [] ): string;

Renders the element widget returning html

Class Phalcon\Forms\Element\Radio

GitHub上のソース

Namespace Phalcon\Forms\Element   Uses Phalcon\Tag, Phalcon\Forms\Element\AbstractElement   Extends AbstractElement

Phalcon\Forms\Element\Radio

Component INPUT[type=radio] for forms

メソッド

public function render( array $attributes = [] ): string;

Renders the element widget returning html

Class Phalcon\Forms\Element\Select

GitHub上のソース

Namespace Phalcon\Forms\Element   Uses Phalcon\Forms\Element\AbstractElement, Phalcon\Tag\Select   Extends AbstractElement

Phalcon\Forms\Element\Select

Component SELECT (choice) for forms

Properties

//
protected optionsValues;

メソッド

public function __construct( string $name, mixed $options = null, mixed $attributes = null ): void;

Phalcon\Forms\Element constructor

@param object array options @param array attributes
public function addOption( mixed $option ): Element;

Adds an option to the current options

@param array option

public function getOptions();

Returns the choices’ options

@return array object
public function render( array $attributes = [] ): string;

Renders the element widget returning html

public function setOptions( mixed $options ): Element;

Set the choice’s options

@param array object options

Class Phalcon\Forms\Element\Submit

GitHub上のソース

Namespace Phalcon\Forms\Element   Uses Phalcon\Tag, Phalcon\Forms\Element\AbstractElement   Extends AbstractElement

Component INPUT[type=submit] for forms

メソッド

public function render( array $attributes = [] ): string;

Renders the element widget

Class Phalcon\Forms\Element\Text

GitHub上のソース

Namespace Phalcon\Forms\Element   Uses Phalcon\Tag, Phalcon\Forms\Element\AbstractElement   Extends AbstractElement

Phalcon\Forms\Element\Text

Component INPUT[type=text] for forms

メソッド

public function render( array $attributes = [] ): string;

Renders the element widget

Class Phalcon\Forms\Element\TextArea

GitHub上のソース

Namespace Phalcon\Forms\Element   Uses Phalcon\Tag, Phalcon\Forms\Element\AbstractElement   Extends AbstractElement

Component TEXTAREA for forms

メソッド

public function render( array $attributes = [] ): string;

Renders the element widget

Class Phalcon\Forms\Exception

GitHub上のソース

Namespace Phalcon\Forms   Extends \Phalcon\Exception

Exceptions thrown in Phalcon\Forms will use this class

Class Phalcon\Forms\Form

GitHub上のソース

Namespace Phalcon\Forms   Uses Countable, Iterator, Phalcon\Di\Injectable, Phalcon\DiInterface, Phalcon\FilterInterface, Phalcon\Filter\FilterInterface, Phalcon\Forms\Exception, Phalcon\Forms\Element\ElementInterface, Phalcon\Html\Attributes, Phalcon\Html\Attributes\AttributesInterface, Phalcon\Messages\Messages, Phalcon\Tag, Phalcon\Validation\Validation, Phalcon\Validation\ValidationInterface   Extends Injectable   Implements Countable, Iterator, AttributesInterface

This component allows to build forms using an object-oriented interface

Properties

//
protected attributes;

//
protected data;

//
protected elements;

//
protected elementsIndexed;

//
protected entity;

//
protected messages;

//
protected position;

//
protected options;

//
protected validation;

メソッド

public function __construct( mixed $entity = null, array $userOptions = [] ): void;

Phalcon\Forms\Form constructor

public function add( ElementInterface $element, string $position = null, bool $type = null ): Form;

Adds an element to the form

public function bind( array $data, mixed $entity, mixed $whitelist = null ): Form;

Binds data to the entity

@param object entity @param array whitelist

public function clear( mixed $fields = null ): Form;

Clears every element in the form to its default value

@param array string null fields
public function count(): int;

Returns the number of elements in the form

public function current(): ElementInterface | bool;

Returns the current element in the iterator

public function get( string $name ): ElementInterface;

Returns an element added to the form by its name

public function getAction(): string;

Returns the form’s action

public function getAttributes(): Attributes;

Get Form attributes collection

public function getElements(): ElementInterface[];

Returns the form elements added to the form

public function getEntity();

Returns the entity related to the model

@return object

public function getLabel( string $name ): string;

Returns a label for an element

public function getMessages(): Messages | array;

Returns the messages generated in the validation.

if ($form->isValid($_POST) == false) {
    $messages = $form->getMessages();

    foreach ($messages as $message) {
        echo $message, "<br>";
    }
}
public function getMessagesFor( string $name ): Messages;

Returns the messages generated for a specific element

public function getUserOption( string $option, mixed $defaultValue = null ): mixed;

Returns the value of an option if present

public function getUserOptions(): array;

Returns the options for the element

public function getValidation()
public function getValue( string $name ): mixed | null;

Gets a value from the internal related entity or from the default value

public function has( string $name ): bool;

Check if the form contains an element

public function hasMessagesFor( string $name ): bool;

Check if messages were generated for a specific element

public function isValid( mixed $data = null, mixed $entity = null ): bool;

Validates the form

@param array data @param object entity

public function key(): int;

イテレータ中の現在の位置/キーを返します。

public function label( string $name, array $attributes = null ): string;

Generate the label of an element added to the form including HTML

public function next(): void;

内部のイテレータの位置を次の位置に移動します。

public function remove( string $name ): bool;

Removes an element from the form

public function render( string $name, array $attributes = [] ): string;

Renders a specific item in the form

public function rewind(): void;

内部のイテレータを巻き戻します。

public function setAction( string $action ): Form;

Sets the form’s action

@return Form

public function setAttributes( Attributes $attributes ): AttributesInterface;

Set form attributes collection

public function setEntity( mixed $entity ): Form;

Sets the entity related to the model

@param object entity

public function setUserOption( string $option, mixed $value ): Form;

Sets an option for the form

public function setUserOptions( array $options ): Form;

Sets options for the element

public function setValidation( $validation )
public function valid(): bool;

Check if the current element in the iterator is valid

Class Phalcon\Forms\Manager

GitHub上のソース

Namespace Phalcon\Forms

Forms Manager

Properties

//
protected forms;

メソッド

public function create( string $name, mixed $entity = null ): Form;

Creates a form registering it in the forms manager

@param object entity

public function get( string $name ): Form;

Returns a form by its name

public function has( string $name ): bool;

Checks if a form is registered in the forms manager

public function set( string $name, Form $form ): FormManager;

Registers a form in the Forms Manager