Sha256: bcb4c88dda0e31f4370f9c39a181ade7ea47282fba1414f3412fb12ff54fcc45
Contents?: true
Size: 914 Bytes
Versions: 13
Compression:
Stored size: 914 Bytes
Contents
# frozen_string_literal: true class Avo::Fields::BooleanGroupField::EditComponent < Avo::Fields::EditComponent def initialize(...) super(...) # Initilize here to avoid multiple calls to @field.get_html for each option. @classes = "w-4 h-4 rounded checked:bg-primary-400 focus:checked:!bg-primary-400" \ "#{@field.get_html(:classes, view: view, element: :input)}" @data = @field.get_html(:data, view: view, element: :input) @style = @field.get_html(:style, view: view, element: :input) @form_scope = @form.object_name end # Get the state of each checkboxe from either the form that returns a validation error or from the model itself. def checked?(id) if params[@form_scope].present? && params[@form_scope][@field.id.to_s].present? params[@form_scope][@field.id.to_s].include?(id.to_s) elsif @field.value.present? @field.value[id.to_s] end end end
Version data entries
13 entries across 13 versions & 1 rubygems