Class: Forms::Group

Inherits:
Phlex::HTML
  • Object
show all
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

Plain::Group

Instance Method Summary collapse

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, **options)
  @legend = legend
  @options = options
  super()
end

Instance Method Details

#view_templateObject



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