lib/cm_admin/models/form_field.rb in cm-admin-2.1.3 vs lib/cm_admin/models/form_field.rb in cm-admin-2.1.4

- old
+ new

@@ -9,25 +9,26 @@ :placeholder, :display_if, :html_attrs, :target, :col_size, :ajax_url, :helper_text VALID_INPUT_TYPES = %i[ integer decimal string single_select multi_select date date_time text switch custom_single_select checkbox_group single_file_upload multi_file_upload hidden rich_text check_box radio_button custom_string custom_date + radio_button_group ].freeze - def initialize(field_name, input_type, attributes = {}) + def initialize(field_name, _input_type, attributes = {}) @field_name = field_name set_default_values attributes.each do |key, value| send("#{key}=", value) end set_default_placeholder - self.display_if = lambda { |arg| return true } if display_if.nil? - raise ArgumentError, "Kindly select a valid input type like #{VALID_INPUT_TYPES.sort.to_sentence(last_word_connector: ', or ')} instead of #{self.input_type} for form field #{field_name}" unless VALID_INPUT_TYPES.include?(self.input_type.to_sym) + self.display_if = ->(_arg) { true } if display_if.nil? + raise ArgumentError, "Kindly select a valid input type like #{VALID_INPUT_TYPES.sort.to_sentence(last_word_connector: ', or ')} instead of #{input_type} for form field #{field_name}" unless VALID_INPUT_TYPES.include?(input_type.to_sym) end def set_default_values - self.disabled = lambda { |arg| return false } if display_if.nil? - self.label = self.field_name.to_s.titleize + self.disabled = ->(_arg) { false } if display_if.nil? + self.label = field_name.to_s.titleize self.input_type = :string self.html_attrs = {} self.target = {} self.col_size = nil end