Skip to content

Commit 448c3e0

Browse files
[2.x] Display validation errors alongside fields in the Inertia stack (#1123)
* Display validation errors alongside the fields * Revert formatting * Update error key for recovery_code * Bump Fortify Co-authored-by: Dale Weaver <[email protected]>
1 parent 02e6849 commit 448c3e0

File tree

8 files changed

+20
-40
lines changed

8 files changed

+20
-40
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"illuminate/console": "^9.21",
2020
"illuminate/support": "^9.21",
2121
"jenssegers/agent": "^2.6",
22-
"laravel/fortify": "^1.12"
22+
"laravel/fortify": "^1.13.3"
2323
},
2424
"require-dev": {
2525
"inertiajs/inertia-laravel": "^0.6.3",

stubs/inertia/resources/js/Components/ValidationErrors.vue

Lines changed: 0 additions & 21 deletions
This file was deleted.

stubs/inertia/resources/js/Pages/Auth/ConfirmPassword.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import JetAuthenticationCard from '@/Components/AuthenticationCard.vue';
55
import JetAuthenticationCardLogo from '@/Components/AuthenticationCardLogo.vue';
66
import JetButton from '@/Components/Button.vue';
77
import JetInput from '@/Components/Input.vue';
8+
import JetInputError from '@/Components/InputError.vue';
89
import JetLabel from '@/Components/Label.vue';
9-
import JetValidationErrors from '@/Components/ValidationErrors.vue';
1010
1111
const form = useForm({
1212
password: '',
@@ -37,8 +37,6 @@ const submit = () => {
3737
This is a secure area of the application. Please confirm your password before continuing.
3838
</div>
3939

40-
<JetValidationErrors class="mb-4" />
41-
4240
<form @submit.prevent="submit">
4341
<div>
4442
<JetLabel for="password" value="Password" />
@@ -52,6 +50,7 @@ const submit = () => {
5250
autocomplete="current-password"
5351
autofocus
5452
/>
53+
<JetInputError class="mt-2" :message="form.errors.password" />
5554
</div>
5655

5756
<div class="flex justify-end mt-4">

stubs/inertia/resources/js/Pages/Auth/ForgotPassword.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import JetAuthenticationCard from '@/Components/AuthenticationCard.vue';
44
import JetAuthenticationCardLogo from '@/Components/AuthenticationCardLogo.vue';
55
import JetButton from '@/Components/Button.vue';
66
import JetInput from '@/Components/Input.vue';
7+
import JetInputError from '@/Components/InputError.vue';
78
import JetLabel from '@/Components/Label.vue';
8-
import JetValidationErrors from '@/Components/ValidationErrors.vue';
99
1010
defineProps({
1111
status: String,
@@ -36,8 +36,6 @@ const submit = () => {
3636
{{ status }}
3737
</div>
3838

39-
<JetValidationErrors class="mb-4" />
40-
4139
<form @submit.prevent="submit">
4240
<div>
4341
<JetLabel for="email" value="Email" />
@@ -49,6 +47,7 @@ const submit = () => {
4947
required
5048
autofocus
5149
/>
50+
<JetInputError class="mt-2" :message="form.errors.email" />
5251
</div>
5352

5453
<div class="flex items-center justify-end mt-4">

stubs/inertia/resources/js/Pages/Auth/Login.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import JetAuthenticationCard from '@/Components/AuthenticationCard.vue';
44
import JetAuthenticationCardLogo from '@/Components/AuthenticationCardLogo.vue';
55
import JetButton from '@/Components/Button.vue';
66
import JetInput from '@/Components/Input.vue';
7+
import JetInputError from '@/Components/InputError.vue';
78
import JetCheckbox from '@/Components/Checkbox.vue';
89
import JetLabel from '@/Components/Label.vue';
9-
import JetValidationErrors from '@/Components/ValidationErrors.vue';
1010
1111
defineProps({
1212
canResetPassword: Boolean,
@@ -37,8 +37,6 @@ const submit = () => {
3737
<JetAuthenticationCardLogo />
3838
</template>
3939

40-
<JetValidationErrors class="mb-4" />
41-
4240
<div v-if="status" class="mb-4 font-medium text-sm text-green-600">
4341
{{ status }}
4442
</div>
@@ -54,6 +52,7 @@ const submit = () => {
5452
required
5553
autofocus
5654
/>
55+
<JetInputError class="mt-2" :message="form.errors.email" />
5756
</div>
5857

5958
<div class="mt-4">
@@ -66,6 +65,7 @@ const submit = () => {
6665
required
6766
autocomplete="current-password"
6867
/>
68+
<JetInputError class="mt-2" :message="form.errors.password" />
6969
</div>
7070

7171
<div class="block mt-4">

stubs/inertia/resources/js/Pages/Auth/Register.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import JetAuthenticationCard from '@/Components/AuthenticationCard.vue';
44
import JetAuthenticationCardLogo from '@/Components/AuthenticationCardLogo.vue';
55
import JetButton from '@/Components/Button.vue';
66
import JetInput from '@/Components/Input.vue';
7+
import JetInputError from '@/Components/InputError.vue';
78
import JetCheckbox from '@/Components/Checkbox.vue';
89
import JetLabel from '@/Components/Label.vue';
9-
import JetValidationErrors from '@/Components/ValidationErrors.vue';
1010
1111
const form = useForm({
1212
name: '',
@@ -31,8 +31,6 @@ const submit = () => {
3131
<JetAuthenticationCardLogo />
3232
</template>
3333

34-
<JetValidationErrors class="mb-4" />
35-
3634
<form @submit.prevent="submit">
3735
<div>
3836
<JetLabel for="name" value="Name" />
@@ -45,6 +43,7 @@ const submit = () => {
4543
autofocus
4644
autocomplete="name"
4745
/>
46+
<JetInputError class="mt-2" :message="form.errors.name" />
4847
</div>
4948

5049
<div class="mt-4">
@@ -56,6 +55,7 @@ const submit = () => {
5655
class="mt-1 block w-full"
5756
required
5857
/>
58+
<JetInputError class="mt-2" :message="form.errors.email" />
5959
</div>
6060

6161
<div class="mt-4">
@@ -68,6 +68,7 @@ const submit = () => {
6868
required
6969
autocomplete="new-password"
7070
/>
71+
<JetInputError class="mt-2" :message="form.errors.password" />
7172
</div>
7273

7374
<div class="mt-4">
@@ -80,6 +81,7 @@ const submit = () => {
8081
required
8182
autocomplete="new-password"
8283
/>
84+
<JetInputError class="mt-2" :message="form.errors.password_confirmation" />
8385
</div>
8486

8587
<div v-if="$page.props.jetstream.hasTermsAndPrivacyPolicyFeature" class="mt-4">

stubs/inertia/resources/js/Pages/Auth/ResetPassword.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import JetAuthenticationCard from '@/Components/AuthenticationCard.vue';
44
import JetAuthenticationCardLogo from '@/Components/AuthenticationCardLogo.vue';
55
import JetButton from '@/Components/Button.vue';
66
import JetInput from '@/Components/Input.vue';
7+
import JetInputError from '@/Components/InputError.vue';
78
import JetLabel from '@/Components/Label.vue';
8-
import JetValidationErrors from '@/Components/ValidationErrors.vue';
99
1010
const props = defineProps({
1111
email: String,
@@ -34,8 +34,6 @@ const submit = () => {
3434
<JetAuthenticationCardLogo />
3535
</template>
3636

37-
<JetValidationErrors class="mb-4" />
38-
3937
<form @submit.prevent="submit">
4038
<div>
4139
<JetLabel for="email" value="Email" />
@@ -47,6 +45,7 @@ const submit = () => {
4745
required
4846
autofocus
4947
/>
48+
<JetInputError class="mt-2" :message="form.errors.email" />
5049
</div>
5150

5251
<div class="mt-4">
@@ -59,6 +58,7 @@ const submit = () => {
5958
required
6059
autocomplete="new-password"
6160
/>
61+
<JetInputError class="mt-2" :message="form.errors.password" />
6262
</div>
6363

6464
<div class="mt-4">
@@ -71,6 +71,7 @@ const submit = () => {
7171
required
7272
autocomplete="new-password"
7373
/>
74+
<JetInputError class="mt-2" :message="form.errors.password_confirmation" />
7475
</div>
7576

7677
<div class="flex items-center justify-end mt-4">

stubs/inertia/resources/js/Pages/Auth/TwoFactorChallenge.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import JetAuthenticationCard from '@/Components/AuthenticationCard.vue';
55
import JetAuthenticationCardLogo from '@/Components/AuthenticationCardLogo.vue';
66
import JetButton from '@/Components/Button.vue';
77
import JetInput from '@/Components/Input.vue';
8+
import JetInputError from '@/Components/InputError.vue';
89
import JetLabel from '@/Components/Label.vue';
9-
import JetValidationErrors from '@/Components/ValidationErrors.vue';
1010
1111
const recovery = ref(false);
1212
@@ -55,8 +55,6 @@ const submit = () => {
5555
</template>
5656
</div>
5757

58-
<JetValidationErrors class="mb-4" />
59-
6058
<form @submit.prevent="submit">
6159
<div v-if="! recovery">
6260
<JetLabel for="code" value="Code" />
@@ -70,6 +68,7 @@ const submit = () => {
7068
autofocus
7169
autocomplete="one-time-code"
7270
/>
71+
<JetInputError class="mt-2" :message="form.errors.code" />
7372
</div>
7473

7574
<div v-else>
@@ -82,6 +81,7 @@ const submit = () => {
8281
class="mt-1 block w-full"
8382
autocomplete="one-time-code"
8483
/>
84+
<JetInputError class="mt-2" :message="form.errors.recovery_code" />
8585
</div>
8686

8787
<div class="flex items-center justify-end mt-4">

0 commit comments

Comments
 (0)