@props([ /** DB column name (or relation name for multiselect). */ 'name', /** Field definition from EntitySectionSchema (type/label/etc.). */ 'def', ]) @php $type = $def['type'] ?? 'text'; $labelKey = $def['label'] ?? null; $label = $labelKey ? __($labelKey) : ucfirst(str_replace('_', ' ', $name)); $dir = $def['dir'] ?? null; $errorRef = "errors['{$name}']"; $labelOptionsKey = $def['label_key'] ?? null; // For `number` fields, look at the validation rules: when `integer` is // declared we want the browser to enforce whole-number entry too. Without // step="1", `step="0.01"` lets users type "5.5" — the form POSTs cleanly // but Laravel rejects with "must be an integer" and the user sees a // generic "couldn't save" toast. $rules = (array) ($def['rules'] ?? []); $isIntegerRule = in_array('integer', $rules, true); $numberStep = $isIntegerRule ? '1' : '0.01'; // Multiselect + textarea + string_list should span the full width // of the grid so chip lists / long text / repeater rows don't get // crammed into one column. $fullWidth = in_array($type, ['multiselect', 'textarea', 'string_list'], true); @endphp