From a36957dd777ff6d35fc9b12ac16d9992efaf6c40 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Wed, 9 Feb 2022 13:12:42 -0600 Subject: [PATCH] Finish the implementation of custom fields default values for checkboxes --- app/Http/Controllers/AssetModelsController.php | 4 +--- .../components/forms/asset-models/fieldset-default-values.vue | 2 +- resources/views/models/custom_fields_form.blade.php | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/AssetModelsController.php b/app/Http/Controllers/AssetModelsController.php index 1e5d5547e3..74ac57f296 100755 --- a/app/Http/Controllers/AssetModelsController.php +++ b/app/Http/Controllers/AssetModelsController.php @@ -155,7 +155,6 @@ class AssetModelsController extends Controller $model->requestable = $request->input('requestable', '0'); - $this->removeCustomFieldsDefaultValues($model); if ($request->input('custom_fieldset')=='') { @@ -464,8 +463,7 @@ class AssetModelsController extends Controller foreach ($defaultValues as $customFieldId => $defaultValue) { if(is_array($defaultValue)){ $model->defaultValues()->attach($customFieldId, ['default_value' => implode(',', $defaultValue)]); - } - if ($defaultValue) { + }elseif ($defaultValue) { $model->defaultValues()->attach($customFieldId, ['default_value' => $defaultValue]); } } diff --git a/resources/assets/js/components/forms/asset-models/fieldset-default-values.vue b/resources/assets/js/components/forms/asset-models/fieldset-default-values.vue index c84fa36c89..96eec2c9a0 100644 --- a/resources/assets/js/components/forms/asset-models/fieldset-default-values.vue +++ b/resources/assets/js/components/forms/asset-models/fieldset-default-values.vue @@ -47,7 +47,7 @@
- +
{$field->db_column_name()})) ? ' checked="checked"' : '') : (Request::old($field->db_column_name()) != '' ? ' checked="checked"' : '') }}> + {$field->db_column_name()})) ? ' checked="checked"' : '') : (Request::old($field->db_column_name()) != '' ? ' checked="checked"' : (in_array($key, explode(',', $field->defaultValue($model->id))) ? ' checked="checked"' : '')) }}> {{ $value }}