{{-- Webform: select which list custom fields appear on the form (data saved to list). Email is always shown (required, no checkbox) and is sortable. --}} @php $selected_ids = $custom_field_ids ? array_map('trim', explode(',', $custom_field_ids)) : []; $selected_ids = array_filter($selected_ids); $list_custom_fields_by_id = $list_custom_fields->keyBy(function ($f) { return (string)($f->id ?? $f->pivot->custom_field_id ?? ''); }); $all_cf_ids = $list_custom_fields->map(function ($f) { return (string)($f->id ?? $f->pivot->custom_field_id ?? ''); })->filter()->values()->toArray(); $base_order = (isset($field_order_array) && !empty($field_order_array)) ? $field_order_array : array_merge(['email'], $all_cf_ids); $field_order = $base_order; foreach ($all_cf_ids as $id) { if (!in_array($id, $field_order)) { $field_order[] = $id; } } if (!in_array('email', $field_order)) { array_unshift($field_order, 'email'); } $field_order_str = implode(',', $field_order); @endphp

{{ __('app.webform_select_fields_help') }}

{{ __('app.webform_drag_to_reorder') }}

@foreach($field_order as $item_id) @if($item_id === 'email') {{-- Email: always shown, required, checkbox checked but disabled (not editable), sortable --}}
@else @php $custom_field = $list_custom_fields_by_id->get($item_id); @endphp @if($custom_field) @php $cf_id = $custom_field->id ?? ($custom_field->pivot->custom_field_id ?? null); @endphp
@endif @endif @endforeach @if($list_custom_fields->isEmpty())

{{ __('app.webform_no_list_fields') }}

@endif