Skip to content

Commit 7261abd

Browse files
committed
An attempt at selective error highlighting
1 parent 5893398 commit 7261abd

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

resources/js/calendar/collapsible_component.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import _ from "lodash";
2+
13
export default class CollapsibleComponent {
24
initialized = false;
35
processWatchers = false;
@@ -109,6 +111,8 @@ export default class CollapsibleComponent {
109111
}
110112

111113
hasError(path) {
114+
console.log(path, _.get(this.errors, path));
112115

116+
return _.get(this.errors, path).length > 0;
113117
}
114118
}

resources/views/components/alpine/text-input.blade.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
data-pt-position="{{ $attributes->get('tooltip-position') ?? 'top' }}"
99
@endif
1010

11-
{{ $attributes->filter(fn (string $value, string $key) => !in_array($key, ['model', 'tooltip', 'tooltip-position']))->merge(['class' => 'protip disabled:text-gray-500 disabled:bg-gray-300 dark:bg-gray-700 dark:border-red-600 dark:text-gray-300 text-gray-600 focus:ring-red-500 focus:border-red-500 block w-full px-2 shadow-sm border-red-300 rounded-md']) }}>
11+
{{ $attributes->filter(fn (string $value, string $key) => !in_array($key, ['model', 'tooltip', 'tooltip-position']))->merge(['class' => 'protip disabled:text-gray-500 disabled:bg-gray-300 dark:bg-gray-700 dark:border-red-600 dark:text-gray-300 text-gray-600 block w-full px-2 shadow-sm rounded-md']) }}
12+
:class="{
13+
'dark:border-red-600 focus:ring-red-500 focus:border-red-500 border-red-300': hasError({{ $attributes->get('path') }})
14+
}"
15+
>
1216

1317
<small class="text-red-600" x-show="hasError({{ $attributes->get('path') }})"
1418
x-text="getError({{ $attributes->get('path') }})"></small>

0 commit comments

Comments
 (0)