From 887de2583351d6a3399f313fbae17492bf319924 Mon Sep 17 00:00:00 2001 From: Faizaan Gagan Date: Fri, 30 Apr 2021 22:59:06 +0530 Subject: [PATCH] FIX: set checkbox field default value as false --- lib/custom_wizard/field.rb | 8 +++++++- serializers/custom_wizard/wizard_field_serializer.rb | 4 ---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/custom_wizard/field.rb b/lib/custom_wizard/field.rb index 51e3d4de..a8160b4c 100644 --- a/lib/custom_wizard/field.rb +++ b/lib/custom_wizard/field.rb @@ -31,7 +31,7 @@ class CustomWizard::Field @index = attrs[:index] @type = attrs[:type] @required = !!attrs[:required] - @value = attrs[:value] + @value = attrs[:value] || default_value @description = attrs[:description] @image = attrs[:image] @key = attrs[:key] @@ -50,6 +50,12 @@ class CustomWizard::Field @label ||= PrettyText.cook(@raw[:label]) end + def default_value + if @type == 'checkbox' + false + end + end + def self.types @types ||= { text: { diff --git a/serializers/custom_wizard/wizard_field_serializer.rb b/serializers/custom_wizard/wizard_field_serializer.rb index 19025dff..42d5eba0 100644 --- a/serializers/custom_wizard/wizard_field_serializer.rb +++ b/serializers/custom_wizard/wizard_field_serializer.rb @@ -40,10 +40,6 @@ class CustomWizard::FieldSerializer < ::ApplicationSerializer object.value end - def include_value? - object.value.present? - end - def i18n_key @i18n_key ||= "wizard.step.#{object.step.id}.fields.#{object.id}".underscore end