lasthourcloud/resources/views/components/inputs/input.blade.php

42 lines
1.3 KiB
PHP
Raw Normal View History

2023-05-03 12:09:10 +00:00
@props([
'id' => null,
2023-05-04 08:00:08 +00:00
'type' => 'text',
2023-05-05 07:28:00 +00:00
'required' => $attributes->has('required'),
2023-05-03 12:09:10 +00:00
'label' => null,
'instantSave' => false,
'disabled' => false,
'hidden' => false,
2023-05-05 07:28:00 +00:00
'noLabel' => false,
'noDirty' => false,
2023-05-03 12:09:10 +00:00
])
2023-05-04 08:00:08 +00:00
<span @class([
'flex justify-end' => $type === 'checkbox',
'flex flex-col' => $type !== 'checkbox',
])>
2023-05-05 07:28:00 +00:00
@if (!$noLabel)
<label for={{ $id }}>
@if ($label)
{{ $label }}
@else
{{ $id }}
@endif
@if ($required)
*
@endif
</label>
@endif
@if ($type === 'textarea')
2023-05-05 07:28:00 +00:00
<textarea @if (!$noDirty) wire:dirty.class="text-black bg-amber-300" @endif {{ $attributes }}
required={{ $required }} type={{ $type }} id={{ $id }} wire:model.defer={{ $id }}></textarea>
@else
2023-05-05 07:28:00 +00:00
<input {{ $attributes }} required={{ $required }}
@if (!$noDirty) wire:dirty.class="text-black bg-amber-300" @endif
type={{ $type }} id={{ $id }}
2023-05-04 13:45:53 +00:00
@if ($instantSave) wire:click='instantSave' wire:model.defer={{ $id }} @else wire:model.defer={{ $value ?? $id }} @endif />
@endif
2023-04-25 12:43:35 +00:00
@error($id)
<div class="text-red-500">{{ $message }}</div>
@enderror
2023-05-04 08:00:08 +00:00
</span>