Class: EasyAdmin::Fields::Form::BooleanComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/easy_admin/fields/form/boolean_component.rb

Instance Attribute Summary

Attributes inherited from BaseComponent

#field, #form, #record, #value

Instance Method Summary collapse

Methods inherited from BaseComponent

#easy_admin_url_helpers, #helpers, #initialize, #rails_url_helpers

Methods included from EasyAdmin::FieldsHelper

#field_component, #render_field

Methods included from DashboardsHelper

#delta_badge_classes, #metric_value_classes, #render_card, #sparkline_color, #sparkline_points, #trend_direction, #trend_icon, #trend_indicator_classes

Constructor Details

This class inherits a constructor from EasyAdmin::Fields::BaseComponent

Instance Method Details

#view_templateObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/components/easy_admin/fields/form/boolean_component.rb', line 5

def view_template
  div(class: "mb-4") do
    div(class: "flex items-center justify-between") do
      div(class: "flex flex-col") do
        label(for: field_id, class: label_classes) do
          plain field_label
          if required?
            span(class: "text-red-500 ml-1") { "*" }
          end
        end

        if field[:help_text]
          p(class: "mt-1 text-sm text-gray-500") { field[:help_text] }
        end
      end

      render_toggle_switch
    end
    render_field_errors
  end
end