<?php /**
 * Field component
 * Thay thế cho việc gọi rời rạc input + label + error
 * Usage:
 * <x-form.field name="email" label="Email" required="true">
 *     <x-ui.forms type="input" typeInput="email" name="email" />
 * </x-form.field>
 */ ?>
@props(['name' => '', 'label' => '', 'required' => false])

<div class="form-group" style="margin-bottom: 16px;">
    @if($label)
        <x-form.label :for="$name" :label="$label" :required="$required" />
    @endif
    
    {{ $slot }}

    @if($name)
        <x-form.input-error :message="$errors->first($name)" />
    @endif
</div>
