0 follower

Interface Yiisoft\FormModel\FormModelInterface

ExtendsYiisoft\Validator\PostValidationHookInterface
Implemented byYiisoft\FormModel\FormModel

Form model represents an HTML form: its data, validation and presentation.

Public Methods

Hide inherited methods

Method Description Defined By
addError() Add an error, the message of which does not require any post-processing. Yiisoft\FormModel\FormModelInterface
getFormName() Returns the form name that this model class should use. Yiisoft\FormModel\FormModelInterface
getPropertyHint() Returns the text hint for the specified property. Yiisoft\FormModel\FormModelInterface
getPropertyHints() Returns the property hints. Yiisoft\FormModel\FormModelInterface
getPropertyLabel() Returns the text label for the specified property. Yiisoft\FormModel\FormModelInterface
getPropertyLabels() Returns the property labels. Yiisoft\FormModel\FormModelInterface
getPropertyPlaceholder() Returns the text placeholder for the specified property. Yiisoft\FormModel\FormModelInterface
getPropertyPlaceholders() Returns the property placeholders. Yiisoft\FormModel\FormModelInterface
getPropertyValue() Get a value for a property specified. Yiisoft\FormModel\FormModelInterface
getValidationResult() Returns validation result. Yiisoft\FormModel\FormModelInterface
hasProperty() If there is such property in the set. Yiisoft\FormModel\FormModelInterface
isValid() Yiisoft\FormModel\FormModelInterface
isValidated() Yiisoft\FormModel\FormModelInterface

Method Details

Hide inherited methods

addError() public abstract method

Add an error, the message of which does not require any post-processing.

See also \Yiisoft\FormModel\Error::addErrorWithoutPostProcessing().

public abstract Yiisoft\FormModel\FormModelInterface addError ( string $message, array $valuePath = [] )
$message string
$valuePath array
return Yiisoft\FormModel\FormModelInterface

Same instance of result.

throws LogicException

When form is not validated.

                public function addError(string $message, array $valuePath = []): static;

            
getFormName() public abstract method

Returns the form name that this model class should use.

The form name is mainly used by {@see \Yiisoft\FormModel\FormModelInputData} to determine how to name the input fields for the properties in a model. If the form name is "A" and a property name is "b", then the corresponding input name would be "A[b]". If the form name is an empty string, then the input name would be "b".

The purpose of the above naming schema is that for forms which contain multiple different models, the properties of each model are grouped in sub-arrays of the POST-data, and it is easier to differentiate between them.

public abstract string getFormName ( )
return string

The form name of this model class.

                public function getFormName(): string;

            
getPropertyHint() public abstract method

Returns the text hint for the specified property.

public abstract string getPropertyHint ( string $property )
$property string

The property name.

return string

The property hint.

                public function getPropertyHint(string $property): string;

            
getPropertyHints() public abstract method

Returns the property hints.

Property hints are mainly used for display purpose. For example, given a property isPublic, we can declare a hint Whether the post should be visible for not logged-in users, which provides user-friendly description of the property meaning and can be displayed to end users.

Unlike label hint will not be generated if its explicit declaration is omitted.

Note, in order to inherit hints defined in the parent class, a child class needs to merge the parent hints with child hints using functions such as array_merge().

public abstract array getPropertyHints ( )
return array

Property hints (name => hint).

                public function getPropertyHints(): array;

            
getPropertyLabel() public abstract method

Returns the text label for the specified property.

public abstract string getPropertyLabel ( string $property )
$property string

The property name.

return string

The property label.

                public function getPropertyLabel(string $property): string;

            
getPropertyLabels() public abstract method

Returns the property labels.

Property labels are mainly used for display purpose. For example, given a property firstName, we can declare a label First Name which is more user-friendly and can be displayed to end users.

By default, a property label is generated automatically. This method allows you to explicitly specify property labels.

Note, in order to inherit labels defined in the parent class, a child class needs to merge the parent labels with child labels using functions such as array_merge().

public abstract array getPropertyLabels ( )
return array

Property labels (name => label).

{@see \Yiisoft\FormModel\getPropertyLabel()}

                public function getPropertyLabels(): array;

            
getPropertyPlaceholder() public abstract method

Returns the text placeholder for the specified property.

public abstract string getPropertyPlaceholder ( string $property )
$property string

The property name.

return string

The property placeholder.

                public function getPropertyPlaceholder(string $property): string;

            
getPropertyPlaceholders() public abstract method

Returns the property placeholders.

public abstract array getPropertyPlaceholders ( )
return array

Property placeholder (name => placeholder).

                public function getPropertyPlaceholders(): array;

            
getPropertyValue() public abstract method

Get a value for a property specified.

public abstract mixed getPropertyValue ( string $property )
$property string

Name of the property.

return mixed

Value.

throws Yiisoft\FormModel\Exception\UndefinedObjectPropertyException
throws Yiisoft\FormModel\Exception\StaticObjectPropertyException
throws Yiisoft\FormModel\Exception\PropertyNotSupportNestedValuesException
throws Yiisoft\FormModel\Exception\ValueNotFoundException

                public function getPropertyValue(string $property): mixed;

            
getValidationResult() public abstract method

Returns validation result.

public abstract \Yiisoft\Validator\Result getValidationResult ( )
return \Yiisoft\Validator\Result

Validation result.

throws LogicException

When validation result is not set.

                public function getValidationResult(): Result;

            
hasProperty() public abstract method

If there is such property in the set.

public abstract boolean hasProperty ( string $property )
$property string

Property name.

return boolean

Whether there's such property.

                public function hasProperty(string $property): bool;

            
isValid() public abstract method

public abstract boolean isValid ( )
return boolean

Whether form data is valid.

                public function isValid(): bool;

            
isValidated() public abstract method

public abstract boolean isValidated ( )
return boolean

Whether form was validated.

                public function isValidated(): bool;