{{-- Always-open scrolling checkbox list backed by an AJAX selectlist endpoint. Behavior lives in the .js-select2-checkboxes-scrollbox init in snipeit.js. Styling in overrides.less under the same name. Submits as a single hidden input containing a comma-separated list of selected ids, sidestepping max_input_vars for very large selections. The server reads with explode(',', $request->input($name)). Props: name : hidden input name and form field. label : control label shown above the scrolling box. endpoint : selectlist endpoint slug (users, companies, ...). selected : array of pre-selected ids (optional). height : max-height of the scrolling box in px (default 400). maxSelectAll : optional per-widget ceiling for ?all=1 (clamped by MAX_UNPAGINATED). help_text : optional help text under the control. --}} @props([ 'name', 'label', 'endpoint', 'selected' => [], 'height' => 400, 'maxSelectAll' => null, 'help_text' => null, 'compactSubmit' => false, ]) @php $listId = $name.'_checkbox_list'; $selectedIds = collect($selected ?? [])->filter()->values(); $selectedCsv = $selectedIds->implode(','); $selectedCount = $selectedIds->count(); @endphp
$errors->has($name)])>
{{-- {n} is the JS-side placeholder convention. Laravel's trans() substitutes `:key` not `{n}`, so render the initial count by hand here and stash the template on data-template for the JS to re-use on every selection change. --}} @php $countTemplate = trans('general.checkbox_multiselect_count'); @endphp {{ str_replace('{n}', $selectedCount, $countTemplate) }}
@if ($compactSubmit) {{-- Single hidden comma-separated input. Server reads with explode(','). JS keeps it in sync as the user ticks rows. Only used for lists with a LOT of items that might hit the php_max_input_vars limit. --}} @else {{-- Container for per-id hidden inputs. JS keeps one name="X[]" input per selected id so the form submits a plain array shape the rest of the app already understands. --}} @endif
@if ($help_text) {!! $help_text !!} @endif