From f8bc753849a275d8d7b389fcf906640135fd6c4d Mon Sep 17 00:00:00 2001 From: Chistel Brown Date: Thu, 25 Jun 2020 09:46:10 +0100 Subject: [PATCH] allow using own already selected checkbox values --- app/Providers/Form.php | 2 +- resources/views/partials/form/checkbox_group.blade.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Providers/Form.php b/app/Providers/Form.php index 245d23c0f..82f739a2d 100644 --- a/app/Providers/Form.php +++ b/app/Providers/Form.php @@ -88,7 +88,7 @@ class Form extends Provider ]); Facade::component('checkboxGroup', 'partials.form.checkbox_group', [ - 'name', 'text', 'items' => [], 'value' => 'name', 'id' => 'id', 'attributes' => ['required' => 'required'], 'col' => 'col-md-12', + 'name', 'text', 'items' => [], 'value' => 'name', 'id' => 'id', 'selected'=>[], 'attributes' => ['required' => 'required'], 'col' => 'col-md-12', ]); Facade::component('fileGroup', 'partials.form.file_group', [ diff --git a/resources/views/partials/form/checkbox_group.blade.php b/resources/views/partials/form/checkbox_group.blade.php index 028ee1e39..fed6c679e 100644 --- a/resources/views/partials/form/checkbox_group.blade.php +++ b/resources/views/partials/form/checkbox_group.blade.php @@ -11,7 +11,7 @@ @foreach($items as $item)
- {{ Form::checkbox($name, $item->$id, null, [ + {{ Form::checkbox($name, $item->$id, (is_array($selected) && count($selected) ? (in_array($item->$id, $selected) ? true : false) : null), [ 'id' => 'checkbox-' . $name . '-' . $item->$id, 'class' => 'custom-control-input', 'v-model' => !empty($attributes['v-model']) ? $attributes['v-model'] : (!empty($attributes['data-field']) ? 'form.' . $attributes['data-field'] . '.'. $name : 'form.' . $name),