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

docs: ✨ Отображение ошибок валидации в шапке формы #528

Merged
merged 1 commit into from
Aug 13, 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
Binary file added public/screenshots/errors_above_false.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/screenshots/errors_above_false_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/screenshots/errors_above_true.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/screenshots/errors_above_true_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions resources/views/pages/en/advanced/form_builder.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
['url' => '#attributes', 'label' => 'Attributes'],
['url' => '#name', 'label' => 'Form name'],
['url' => '#async', 'label' => 'Asynchronous mode'],
['url' => '#errors', 'label' => 'Displaying validation errors'],
['url' => '#precognitive', 'label' => 'Precognitive'],
['url' => '#apply', 'label' => 'Apply'],
['url' => '#method', 'label' => 'Calling methods'],
Expand Down Expand Up @@ -325,6 +326,26 @@
The <code>async()</code> method must come after the <code>name()</code> method!
</x-moonshine::alert>

<x-sub-title id="errors">Displaying validation errors</x-sub-title>
<x-p>
By default, validation errors are displayed at the top of the form.
</x-p>

<x-image theme="light" src="{{ asset('screenshots/errors_above_true.png') }}"></x-image>
<x-image theme="dark" src="{{ asset('screenshots/errors_above_true_dark.png') }}"></x-image>

<x-p>
The <code>errorsAbove(bool $enable = true)</code> method is used to control the display of validation errors at the top of the form. It allows you to enable or disable this feature.
</x-p>

<x-code language="php">
FormBuilder::make('/crud/update', 'PUT')
->errorsAbove(false) // [tl! focus]
</x-code>

<x-image theme="light" src="{{ asset('screenshots/errors_above_false.png') }}"></x-image>
<x-image theme="dark" src="{{ asset('screenshots/errors_above_false_dark.png') }}"></x-image>

<x-sub-title id="precognitive">Precognitive</x-sub-title>

<x-p>
Expand Down
27 changes: 27 additions & 0 deletions resources/views/pages/en/resources/validation.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<x-page title="Validation" :sectionMenu="[
'Sections' => [
['url' => '#basics', 'label' => 'Basics'],
['url' => '#errors', 'label' => 'Displaying validation errors'],
['url' => '#messages', 'label' => 'Messages'],
['url' => '#prepare', 'label' => 'Preparing Input For Validation'],
]
Expand Down Expand Up @@ -38,6 +39,32 @@ public function rules($item): array // [tl! focus:start]

<x-image theme="light" src="{{ asset('screenshots/validation.png') }}"></x-image>
<x-image theme="dark" src="{{ asset('screenshots/validation_dark.png') }}"></x-image>
<x-sub-title id="errors">Displaying validation errors</x-sub-title>
<x-p>
The <code>$errorsAbove</code> resource parameter is responsible for displaying validation errors at the top of the form. The default value is <code>true</code>, which means that validation errors will be displayed.
</x-p>

<x-image theme="light" src="{{ asset('screenshots/errors_above_true.png') }}"></x-image>
<x-image theme="dark" src="{{ asset('screenshots/errors_above_true_dark.png') }}"></x-image>

<x-p>
To hide validation errors at the top of the form, set the <code>$errorsAbove</code> resource parameter to <code>false</code>.
</x-p>
<x-code language="php">
namespace App\MoonShine\Resources;

use MoonShine\Resources\ModelResource;

class PostResource extends ModelResource
{
//...
protected bool $errorsAbove = false;// [tl! focus]
//...
}
</x-code>

<x-image theme="light" src="{{ asset('screenshots/errors_above_false.png') }}"></x-image>
<x-image theme="dark" src="{{ asset('screenshots/errors_above_false_dark.png') }}"></x-image>

<x-sub-title id="messages">Messages</x-sub-title>

Expand Down
21 changes: 21 additions & 0 deletions resources/views/pages/ru/advanced/form_builder.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
['url' => '#attributes', 'label' => 'Атрибуты'],
['url' => '#name', 'label' => 'Наименование формы'],
['url' => '#async', 'label' => 'Асинхронный режим'],
['url' => '#errors', 'label' => 'Отображение ошибок валидации'],
['url' => '#precognitive', 'label' => 'Precognitive'],
['url' => '#apply', 'label' => 'Apply'],
['url' => '#method', 'label' => 'Вызов методов'],
Expand Down Expand Up @@ -325,6 +326,26 @@
Метод <code>async()</code> должен быть после метода <code>name()</code>!
</x-moonshine::alert>

<x-sub-title id="errors">Отображение ошибок валидации</x-sub-title>
<x-p>
По умолчанию ошибки валидации отображаются в верхней части формы.
</x-p>

<x-image theme="light" src="{{ asset('screenshots/errors_above_true.png') }}"></x-image>
<x-image theme="dark" src="{{ asset('screenshots/errors_above_true_dark.png') }}"></x-image>

<x-p>
Метод <code>errorsAbove(bool $enable = true)</code> используется для управления отображением ошибок валидации в верхней части формы. Он позволяет включить или отключить эту функцию.
</x-p>

<x-code language="php">
FormBuilder::make('/crud/update', 'PUT')
->errorsAbove(false) // [tl! focus]
</x-code>

<x-image theme="light" src="{{ asset('screenshots/errors_above_false.png') }}"></x-image>
<x-image theme="dark" src="{{ asset('screenshots/errors_above_false_dark.png') }}"></x-image>

<x-sub-title id="precognitive">Precognitive</x-sub-title>

<x-p>
Expand Down
28 changes: 28 additions & 0 deletions resources/views/pages/ru/resources/validation.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<x-page title="Валидация" :sectionMenu="[
'Разделы' => [
['url' => '#basics', 'label' => 'Основы'],
['url' => '#errors', 'label' => 'Отображение ошибок валидации'],
['url' => '#messages', 'label' => 'Сообщения'],
['url' => '#prepare', 'label' => 'Подготовка входных данных'],
]
Expand Down Expand Up @@ -39,6 +40,33 @@ public function rules($item): array // [tl! focus:start]
<x-image theme="light" src="{{ asset('screenshots/validation.png') }}"></x-image>
<x-image theme="dark" src="{{ asset('screenshots/validation_dark.png') }}"></x-image>

<x-sub-title id="errors">Отображение ошибок валидации</x-sub-title>
<x-p>
Параметр ресурса <code>$errorsAbove</code> отвечает за отображение ошибок валидации в верхней части формы. По умолчанию установлено значение <code>true</code>, что означает, что ошибки валидации будут отображаться.
</x-p>

<x-image theme="light" src="{{ asset('screenshots/errors_above_true.png') }}"></x-image>
<x-image theme="dark" src="{{ asset('screenshots/errors_above_true_dark.png') }}"></x-image>

<x-p>
Чтобы скрыть ошибки валидации в верхней части формы, установите для параметра ресурса <code>$errorsAbove</code> значение <code>false</code>.
</x-p>
<x-code language="php">
namespace App\MoonShine\Resources;

use MoonShine\Resources\ModelResource;

class PostResource extends ModelResource
{
//...
protected bool $errorsAbove = false;// [tl! focus]
//...
}
</x-code>

<x-image theme="light" src="{{ asset('screenshots/errors_above_false.png') }}"></x-image>
<x-image theme="dark" src="{{ asset('screenshots/errors_above_false_dark.png') }}"></x-image>

<x-sub-title id="messages">Сообщения</x-sub-title>

<x-p>
Expand Down
Loading