Class: Phlexi::Form::Structure::FieldCollection::Builder

Inherits:
Phlexi::Field::Structure::FieldCollection::Builder
  • Object
show all
Defined in:
lib/phlexi/form/structure/field_collection.rb

Instance Method Summary collapse

Instance Method Details

#field(**options) ⇒ Object



8
9
10
11
12
13
# File 'lib/phlexi/form/structure/field_collection.rb', line 8

def field(**options)
  options = mix({input_attributes: @field.input_attributes}, options)
  @field.class.new(key, **options, parent: @field).tap do |field|
    yield field if block_given?
  end
end

#hidden_field_tag(value: "", force: false) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/phlexi/form/structure/field_collection.rb', line 15

def hidden_field_tag(value: "", force: false)
  raise "Attempting to build hidden field on non-first field in a collection" unless index == 0 || force

  @field.class
    .new("hidden", parent: @field)
    .input_tag(type: :hidden, value:)
end