Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #66

Merged
merged 5 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The package provides a base for form models and helps to fill them with data, va
## Requirements

- PHP 8.1 or higher.
- `mbstring` PHP extension.

## Installation

Expand Down Expand Up @@ -87,17 +88,9 @@ Display it using [fields](docs/guide/en/displaying-fields.md) in the view:
use Yiisoft\FormModel\Field;
use Yiisoft\FormModel\FormModel;

if (!empty($errors)) {
foreach ($errors as $property => $errorMessage) {
// Display an error message.
<p><?= Html::encode($errorMessage) ?></p>
}
}

// Display a field.

/** @var FormModel $formModel */
echo Field::text($formModel, 'login');
echo Field::password($formModel, 'password');
echo Field::checkbox($formModel, 'rememberMe');

// ...
```
Expand Down
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "yiisoft/form-model",
"type": "library",
"description": "_____",
"description": "Provides a base for form models and helps to fill, validate and display them.",
"keywords": [
"_____"
"form",
"model"
],
"homepage": "https://www.yiiframework.com/",
"license": "BSD-3-Clause",
Expand All @@ -25,13 +26,11 @@
"url": "https://github.com/sponsors/yiisoft"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^8.1",
"ext-mbstring": "*",
"psr/http-message": "^1.0|^2.0",
"yiisoft/form": "^1.0@dev",
"yiisoft/form": "^1.0",
"yiisoft/html": "^3.3",
"yiisoft/hydrator": "^1.3",
"yiisoft/strings": "^2.3",
Expand Down
2 changes: 1 addition & 1 deletion src/Attribute/Hint.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
final class Hint
{
public function __construct(
private string $hint,
private readonly string $hint,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Attribute/Placeholder.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
final class Placeholder
{
public function __construct(
private string $placeholder,
private readonly string $placeholder,
) {
}

Expand Down
7 changes: 2 additions & 5 deletions src/FormModelInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,14 @@ public function getPropertyPlaceholders(): array;
/**
* Returns the form name that this model class should use.
*
* The form name is mainly used by {@see TODO: FIX NAMESPACE HtmlForm} to determine how to name the input
* fields for the properties in a model.
* The form name is mainly used by {@see 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.
*
* By default, this method returns the model class name (without the namespace part) as the form name. You may
* override it when the model is used in different forms.
*
* @return string The form name of this model class.
*/
public function getFormName(): string;
Expand Down
2 changes: 2 additions & 0 deletions src/NonArrayTypeCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use Yiisoft\Hydrator\TypeCaster\TypeCastContext;
use Yiisoft\Hydrator\TypeCaster\TypeCasterInterface;

use function is_array;

/**
* Ensures that non-array value for property of array type is converted to an empty array.
*/
Expand Down
Loading