{{-- Formulário de uma seção de configuração (CMS), gerado do schema do Core (ADR-046). O módulo preenche **apenas** o conteúdo; o shell é dono da estrutura e do título (ADR-016). --}} @php $firstError = $errors->any() ? $errors->keys()[0] : null; @endphp @if (session('status')) {{ session('status') }} @endif
@csrf @method('PUT') @foreach ($fields as $key => $field) @php $type = $field['type']; $fieldLabel = __($field['label']); $help = isset($field['help']) ? __($field['help']) : null; $required = ($field['required'] ?? false) === true; $maxlength = $field['max'] ?? null; $value = $values[$key] ?? null; $describedBy = array_values(array_filter([ $help !== null ? 'field-'.$key.'-help' : null, $errors->has($key) ? 'field-'.$key.'-error' : null, ])); $inputType = match ($type) { 'email' => 'email', 'url' => 'url', 'phone' => 'tel', 'secret' => 'password', 'int' => 'number', default => 'text', }; @endphp @if ($type === 'json') {{-- Documento JSON (ex.: redes sociais): o editor genérico não edita objeto aninhado nesta fatia (P1.S2/S3/P14). O formulário devolve o documento intacto para uma seção salva não perder dado que não edita. --}} @php $encodedJson = is_array($value) ? json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) : ''; // `old()` pode ser array num POST forjado (`social[]=x`): `htmlspecialchars` // sobre array é fatal, então só uma string volta ao campo oculto. $oldJson = old($key); $hiddenJson = is_string($oldJson) ? $oldJson : (is_string($encodedJson) ? $encodedJson : ''); @endphp @elseif ($type === 'text')
@if ($help !== null) {{ $help }} @endif @error($key) {{ $message }} @enderror
@elseif ($type === 'bool')
@if ($help !== null) {{ $help }} @endif @error($key) {{ $message }} @enderror
@elseif ($type === 'enum')
@if ($help !== null) {{ $help }} @endif @error($key) {{ $message }} @enderror
@else @endif @endforeach
{{ __('configuracoes::cms.save') }} {{ __('configuracoes::cms.cancel') }}