Class: UI::FieldSetComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
FieldSetBehavior
Defined in:
app/view_components/ui/field_set_component.rb

Overview

FieldSetComponent - ViewComponent implementation

Semantic fieldset container for grouped fields. Uses FieldSetBehavior concern for shared styling logic.

Examples:

Basic usage

<%= render UI::FieldSetComponent.new do %>
  <%= render UI::FieldLegendComponent.new do %>
    Contact Information
  <% end %>
  Field groups here
<% end %>

Instance Method Summary collapse

Methods included from FieldSetBehavior

#field_set_classes, #field_set_html_attributes

Constructor Details

#initialize(classes: "", **attributes) ⇒ FieldSetComponent

Returns a new instance of FieldSetComponent.

Parameters:

  • classes (String) (defaults to: "") —

    Additional CSS classes to merge

  • attributes (Hash) —

    Additional HTML attributes



20
21
22
23
# File 'app/view_components/ui/field_set_component.rb', line 20

def initialize(classes: "", **attributes)
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#call ⇒ Object



25
26
27
28
29
# File 'app/view_components/ui/field_set_component.rb', line 25

def call
   :fieldset, **field_set_html_attributes do
    content
  end
end