Interface Yiisoft\FormModel\FormModelInterface
| Extends | Yiisoft\Validator\PostValidationHookInterface |
|---|---|
| Implemented by | Yiisoft\FormModel\FormModel |
Form model represents an HTML form: its data, validation and presentation.
Public Methods
Method Details
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;
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;
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;
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;
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;
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;
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;
Returns the property placeholders.
| public abstract array getPropertyPlaceholders ( ) | ||
| return | array |
Property placeholder (name => placeholder). |
|---|---|---|
public function getPropertyPlaceholders(): array;
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;
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;
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;
| public abstract boolean isValid ( ) | ||
| return | boolean |
Whether form data is valid. |
|---|---|---|
public function isValid(): bool;
| public abstract boolean isValidated ( ) | ||
| return | boolean |
Whether form was validated. |
|---|---|---|
public function isValidated(): bool;
Signup or Login in order to comment.