Skip to content

Commit

Permalink
fix: Field id/for
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-to committed Dec 9, 2024
1 parent d21962d commit fb99197
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/UI/resources/views/components/field-container.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{-- @internal --}}
@props([
'label' => '',
'formName' => '',
'errors' => [],
'isBeforeLabel' => false,
'isInsideLabel' => false,
Expand All @@ -13,6 +14,7 @@

<x-moonshine::form.wrapper
label="{{ $label }}"
:form-name="$formName"
:attributes="$attributes"
:beforeLabel="$isBeforeLabel"
:insideLabel="$isInsideLabel"
Expand Down
5 changes: 3 additions & 2 deletions src/UI/resources/views/components/form/wrapper.blade.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
@props([
'label' => '',
'formName' => '',
'fieldErrors' => [],
'beforeLabel' => false,
'insideLabel' => false,
'before',
'after',
])
<div {{ $attributes->merge(['class' => 'form-group moonshine-field'])->except('required') }}
x-id="['input-wrapper', 'field']" :id="$id('input-wrapper')"
x-id="['input-wrapper', 'field-{{ $formName }}']" :id="$id('input-wrapper')"
>
{{ $beforeLabel && !$insideLabel ? $slot : '' }}

@if($label)
<x-moonshine::form.label
:required="$attributes->get('required', false)"
::for="$id('field')"
::for="$id('field-{{ $formName }}')"
>
{{ $beforeLabel && $insideLabel ? $slot : '' }}
{!! $label !!}
Expand Down
1 change: 1 addition & 0 deletions src/UI/src/Fields/FieldContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ protected function viewData(): array
{
return [
'label' => $this->field->getLabel(),
'formName' => $this->field->getFormName(),

'errors' => data_get($this->field->getErrors(), $this->field->getNameDot()),

Expand Down

0 comments on commit fb99197

Please sign in to comment.