Skip to content

Commit

Permalink
[2.x] Display validation errors alongside fields in the Inertia stack (
Browse files Browse the repository at this point in the history
…#1123)

* Display validation errors alongside the fields

* Revert formatting

* Update error key for recovery_code

* Bump Fortify

Co-authored-by: Dale Weaver <[email protected]>
  • Loading branch information
jessarcher and daleweaver777 authored Aug 16, 2022
1 parent 02e6849 commit 448c3e0
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 40 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"illuminate/console": "^9.21",
"illuminate/support": "^9.21",
"jenssegers/agent": "^2.6",
"laravel/fortify": "^1.12"
"laravel/fortify": "^1.13.3"
},
"require-dev": {
"inertiajs/inertia-laravel": "^0.6.3",
Expand Down
21 changes: 0 additions & 21 deletions stubs/inertia/resources/js/Components/ValidationErrors.vue

This file was deleted.

5 changes: 2 additions & 3 deletions stubs/inertia/resources/js/Pages/Auth/ConfirmPassword.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import JetAuthenticationCard from '@/Components/AuthenticationCard.vue';
import JetAuthenticationCardLogo from '@/Components/AuthenticationCardLogo.vue';
import JetButton from '@/Components/Button.vue';
import JetInput from '@/Components/Input.vue';
import JetInputError from '@/Components/InputError.vue';
import JetLabel from '@/Components/Label.vue';
import JetValidationErrors from '@/Components/ValidationErrors.vue';
const form = useForm({
password: '',
Expand Down Expand Up @@ -37,8 +37,6 @@ const submit = () => {
This is a secure area of the application. Please confirm your password before continuing.
</div>

<JetValidationErrors class="mb-4" />

<form @submit.prevent="submit">
<div>
<JetLabel for="password" value="Password" />
Expand All @@ -52,6 +50,7 @@ const submit = () => {
autocomplete="current-password"
autofocus
/>
<JetInputError class="mt-2" :message="form.errors.password" />
</div>

<div class="flex justify-end mt-4">
Expand Down
5 changes: 2 additions & 3 deletions stubs/inertia/resources/js/Pages/Auth/ForgotPassword.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import JetAuthenticationCard from '@/Components/AuthenticationCard.vue';
import JetAuthenticationCardLogo from '@/Components/AuthenticationCardLogo.vue';
import JetButton from '@/Components/Button.vue';
import JetInput from '@/Components/Input.vue';
import JetInputError from '@/Components/InputError.vue';
import JetLabel from '@/Components/Label.vue';
import JetValidationErrors from '@/Components/ValidationErrors.vue';
defineProps({
status: String,
Expand Down Expand Up @@ -36,8 +36,6 @@ const submit = () => {
{{ status }}
</div>

<JetValidationErrors class="mb-4" />

<form @submit.prevent="submit">
<div>
<JetLabel for="email" value="Email" />
Expand All @@ -49,6 +47,7 @@ const submit = () => {
required
autofocus
/>
<JetInputError class="mt-2" :message="form.errors.email" />
</div>

<div class="flex items-center justify-end mt-4">
Expand Down
6 changes: 3 additions & 3 deletions stubs/inertia/resources/js/Pages/Auth/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import JetAuthenticationCard from '@/Components/AuthenticationCard.vue';
import JetAuthenticationCardLogo from '@/Components/AuthenticationCardLogo.vue';
import JetButton from '@/Components/Button.vue';
import JetInput from '@/Components/Input.vue';
import JetInputError from '@/Components/InputError.vue';
import JetCheckbox from '@/Components/Checkbox.vue';
import JetLabel from '@/Components/Label.vue';
import JetValidationErrors from '@/Components/ValidationErrors.vue';
defineProps({
canResetPassword: Boolean,
Expand Down Expand Up @@ -37,8 +37,6 @@ const submit = () => {
<JetAuthenticationCardLogo />
</template>

<JetValidationErrors class="mb-4" />

<div v-if="status" class="mb-4 font-medium text-sm text-green-600">
{{ status }}
</div>
Expand All @@ -54,6 +52,7 @@ const submit = () => {
required
autofocus
/>
<JetInputError class="mt-2" :message="form.errors.email" />
</div>

<div class="mt-4">
Expand All @@ -66,6 +65,7 @@ const submit = () => {
required
autocomplete="current-password"
/>
<JetInputError class="mt-2" :message="form.errors.password" />
</div>

<div class="block mt-4">
Expand Down
8 changes: 5 additions & 3 deletions stubs/inertia/resources/js/Pages/Auth/Register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import JetAuthenticationCard from '@/Components/AuthenticationCard.vue';
import JetAuthenticationCardLogo from '@/Components/AuthenticationCardLogo.vue';
import JetButton from '@/Components/Button.vue';
import JetInput from '@/Components/Input.vue';
import JetInputError from '@/Components/InputError.vue';
import JetCheckbox from '@/Components/Checkbox.vue';
import JetLabel from '@/Components/Label.vue';
import JetValidationErrors from '@/Components/ValidationErrors.vue';
const form = useForm({
name: '',
Expand All @@ -31,8 +31,6 @@ const submit = () => {
<JetAuthenticationCardLogo />
</template>

<JetValidationErrors class="mb-4" />

<form @submit.prevent="submit">
<div>
<JetLabel for="name" value="Name" />
Expand All @@ -45,6 +43,7 @@ const submit = () => {
autofocus
autocomplete="name"
/>
<JetInputError class="mt-2" :message="form.errors.name" />
</div>

<div class="mt-4">
Expand All @@ -56,6 +55,7 @@ const submit = () => {
class="mt-1 block w-full"
required
/>
<JetInputError class="mt-2" :message="form.errors.email" />
</div>

<div class="mt-4">
Expand All @@ -68,6 +68,7 @@ const submit = () => {
required
autocomplete="new-password"
/>
<JetInputError class="mt-2" :message="form.errors.password" />
</div>

<div class="mt-4">
Expand All @@ -80,6 +81,7 @@ const submit = () => {
required
autocomplete="new-password"
/>
<JetInputError class="mt-2" :message="form.errors.password_confirmation" />
</div>

<div v-if="$page.props.jetstream.hasTermsAndPrivacyPolicyFeature" class="mt-4">
Expand Down
7 changes: 4 additions & 3 deletions stubs/inertia/resources/js/Pages/Auth/ResetPassword.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import JetAuthenticationCard from '@/Components/AuthenticationCard.vue';
import JetAuthenticationCardLogo from '@/Components/AuthenticationCardLogo.vue';
import JetButton from '@/Components/Button.vue';
import JetInput from '@/Components/Input.vue';
import JetInputError from '@/Components/InputError.vue';
import JetLabel from '@/Components/Label.vue';
import JetValidationErrors from '@/Components/ValidationErrors.vue';
const props = defineProps({
email: String,
Expand Down Expand Up @@ -34,8 +34,6 @@ const submit = () => {
<JetAuthenticationCardLogo />
</template>

<JetValidationErrors class="mb-4" />

<form @submit.prevent="submit">
<div>
<JetLabel for="email" value="Email" />
Expand All @@ -47,6 +45,7 @@ const submit = () => {
required
autofocus
/>
<JetInputError class="mt-2" :message="form.errors.email" />
</div>

<div class="mt-4">
Expand All @@ -59,6 +58,7 @@ const submit = () => {
required
autocomplete="new-password"
/>
<JetInputError class="mt-2" :message="form.errors.password" />
</div>

<div class="mt-4">
Expand All @@ -71,6 +71,7 @@ const submit = () => {
required
autocomplete="new-password"
/>
<JetInputError class="mt-2" :message="form.errors.password_confirmation" />
</div>

<div class="flex items-center justify-end mt-4">
Expand Down
6 changes: 3 additions & 3 deletions stubs/inertia/resources/js/Pages/Auth/TwoFactorChallenge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import JetAuthenticationCard from '@/Components/AuthenticationCard.vue';
import JetAuthenticationCardLogo from '@/Components/AuthenticationCardLogo.vue';
import JetButton from '@/Components/Button.vue';
import JetInput from '@/Components/Input.vue';
import JetInputError from '@/Components/InputError.vue';
import JetLabel from '@/Components/Label.vue';
import JetValidationErrors from '@/Components/ValidationErrors.vue';
const recovery = ref(false);
Expand Down Expand Up @@ -55,8 +55,6 @@ const submit = () => {
</template>
</div>

<JetValidationErrors class="mb-4" />

<form @submit.prevent="submit">
<div v-if="! recovery">
<JetLabel for="code" value="Code" />
Expand All @@ -70,6 +68,7 @@ const submit = () => {
autofocus
autocomplete="one-time-code"
/>
<JetInputError class="mt-2" :message="form.errors.code" />
</div>

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

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

0 comments on commit 448c3e0

Please sign in to comment.