@props([ 'name', 'label' => null, 'value' => null, /** * date | time | datetime * * Named rather than inferred from the HTML type, so a field says what it * means. "datetime" is one value in one column — a date and a time picked * separately are two fields and the form combines them. */ 'mode' => 'date', 'required' => false, 'min' => null, 'max' => null, 'help' => null, 'placeholder' => null, ]) {{-- The application's date and time field. One component so every date in the clinic looks and behaves the same — the rule being that Flatpickr is the only picker in this product and nothing reaches for a second one. There is no JavaScript here. The behaviour lives in resources/js/app.js, which finds this field by its type and enhances it: the Content-Security- Policy refuses inline scripts, and a per-field initialiser would be the duplication this component exists to avoid. Degrades honestly. Before the script runs, or if it never does, this is an ordinary date input — the browser's own picker, the same value, the same submission. --}} @php $id = $attributes->get('id', $name); $old = old($name, $value); $type = match ($mode) { 'time' => 'time', 'datetime' => 'datetime-local', default => 'date', }; @endphp
only('class')->merge(['class' => 'mb-3']) }}> @if ($label) @endif except(['class', 'id']) }} class="form-control px-input @error($name) is-invalid @enderror"> @error($name)
{{ $message }}
@enderror @if ($help) {{ $help }} @endif