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

41 lines
1.4 KiB
PHP
Raw Normal View History

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