Class: Forms::Group
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- Forms::Group
- Defined in:
- lib/forms/group.rb
Overview
A daisyui fieldset with an optional legend, for sectioning related fields.
Exposed as f.group (not section/fieldset — those are Phlex::HTML
element methods and defining them would shadow the elements inside forms).
f.group(legend: "Address") { f.field :street; f.field :city }
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(legend: nil, **options) ⇒ Group
constructor
A new instance of Group.
- #view_template ⇒ Object
Constructor Details
#initialize(legend: nil, **options) ⇒ Group
Returns a new instance of Group.
10 11 12 13 14 |
# File 'lib/forms/group.rb', line 10 def initialize(legend: nil, **) @legend = legend @options = super() end |
Instance Method Details
#view_template ⇒ Object
16 17 18 19 20 21 |
# File 'lib/forms/group.rb', line 16 def view_template render DaisyUI::Fieldset.new(**@options) do |fs| fs.legend { @legend } if @legend yield if block_given? end end |