mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Configuration option
refactored code to be a configuration option rather than hardcoding the type.
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
@props([
|
||||
'disabled' => false,
|
||||
'id' => null,
|
||||
'prefix' => null,
|
||||
'required' => false,
|
||||
'suffix' => null,
|
||||
])
|
||||
|
||||
<div
|
||||
id="{{ $id }}"
|
||||
|
||||
{{ $attributes->class(['fi-fo-field-wrp-label inline-flex items-center gap-x-3']) }}
|
||||
>
|
||||
{{ $prefix }}
|
||||
|
||||
<span class="text-sm font-medium leading-6 text-gray-950 dark:text-white">
|
||||
{{-- Deliberately poor formatting to ensure that the asterisk sticks to the final word in the label. --}}
|
||||
{{ $slot }}@if ($required && (! $disabled))<sup class="text-danger-600 dark:text-danger-400 font-medium">*</sup>
|
||||
@endif
|
||||
</span>
|
||||
|
||||
{{ $suffix }}
|
||||
</div>
|
||||
@@ -21,6 +21,7 @@
|
||||
'labelSuffix' => null,
|
||||
'required' => null,
|
||||
'statePath' => null,
|
||||
'useDivLabel' => false,
|
||||
])
|
||||
|
||||
@php
|
||||
@@ -47,8 +48,6 @@
|
||||
);
|
||||
|
||||
$hasError = filled($statePath) && ($errors->has($statePath) || ($hasNestedRecursiveValidationRules && $errors->has("{$statePath}.*")));
|
||||
|
||||
$isFileUploadComponent = $field instanceof \Filament\Forms\Components\FileUpload;
|
||||
@endphp
|
||||
|
||||
<div
|
||||
@@ -61,7 +60,7 @@
|
||||
>
|
||||
@if ($label && $labelSrOnly)
|
||||
<label
|
||||
@if ($isFileUploadComponent)
|
||||
@if ($useDivLabel)
|
||||
:id="$id . '-label'"
|
||||
@else
|
||||
:for="$id"
|
||||
@@ -93,27 +92,17 @@
|
||||
])
|
||||
>
|
||||
@if ($label && (! $labelSrOnly))
|
||||
@if (!$isFileUploadComponent)
|
||||
<x-filament-forms::field-wrapper.label
|
||||
:for="$id"
|
||||
:disabled="$isDisabled"
|
||||
:prefix="$labelPrefix"
|
||||
:required="$required"
|
||||
:suffix="$labelSuffix"
|
||||
>
|
||||
{{ $label }}
|
||||
</x-filament-forms::field-wrapper.label>
|
||||
@else
|
||||
<x-filament-forms::field-wrapper.file-upload-label
|
||||
:id="$id . '-label'"
|
||||
:disabled="$isDisabled"
|
||||
:prefix="$labelPrefix"
|
||||
:required="$required"
|
||||
:suffix="$labelSuffix"
|
||||
>
|
||||
{{ $label }}
|
||||
</x-filament-forms::field-wrapper.file-upload-label>
|
||||
@endif
|
||||
<x-filament-forms::field-wrapper.label
|
||||
:for="$useDivLabel ? null : $id"
|
||||
:id="$useDivLabel ? ($id . '-label') : null"
|
||||
:use-div-label="$useDivLabel"
|
||||
:disabled="$isDisabled"
|
||||
:prefix="$labelPrefix"
|
||||
:required="$required"
|
||||
:suffix="$labelSuffix"
|
||||
>
|
||||
{{ $label }}
|
||||
</x-filament-forms::field-wrapper.label>
|
||||
@elseif ($labelPrefix)
|
||||
{{ $labelPrefix }}
|
||||
@elseif ($labelSuffix)
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
'prefix' => null,
|
||||
'required' => false,
|
||||
'suffix' => null,
|
||||
'useDivLabel' => false,
|
||||
])
|
||||
|
||||
<label
|
||||
<{{ $useDivLabel ? 'div' : 'label' }}
|
||||
{{ $attributes->class(['fi-fo-field-wrp-label inline-flex items-center gap-x-3']) }}
|
||||
>
|
||||
{{ $prefix }}
|
||||
@@ -17,4 +18,4 @@
|
||||
</span>
|
||||
|
||||
{{ $suffix }}
|
||||
</label>
|
||||
</{{ $useDivLabel ? 'div' : 'label' }}>
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
:component="$getFieldWrapperView()"
|
||||
:field="$field"
|
||||
:label-sr-only="$isLabelHidden()"
|
||||
:use-div-label="true"
|
||||
>
|
||||
<div
|
||||
@if (FilamentView::hasSpaMode())
|
||||
|
||||
Reference in New Issue
Block a user