Class: Interview::Form

Inherits:
Control show all
Includes:
HasHtmlOptions, NestedBuildable
Defined in:
lib/interview/controls/form.rb

Direct Known Subclasses

ScaffoldForm

Instance Attribute Summary collapse

Attributes included from HasHtmlOptions

#html_class, #html_options

Attributes inherited from Control

#parent

Instance Method Summary collapse

Methods included from HasHtmlOptions

#initialize

Methods included from NestedBuildable

#create_nested_builder, #render_nested_builder

Methods inherited from Control

#ancestors, #build_child, #build_with_params, #find_attribute, #find_attribute!, #initialize, #set_attributes, #set_defaults

Instance Attribute Details

#form_builderObject (readonly)

Returns the value of attribute form_builder.



7
8
9
# File 'lib/interview/controls/form.rb', line 7

def form_builder
  @form_builder
end

#objectObject

Returns the value of attribute object.



6
7
8
# File 'lib/interview/controls/form.rb', line 6

def object
  @object
end

#redirect_toObject

Returns the value of attribute redirect_to.



6
7
8
# File 'lib/interview/controls/form.rb', line 6

def redirect_to
  @redirect_to
end

Instance Method Details

#build(b) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/interview/controls/form.rb', line 9

def build(b)
  object = @object || find_attribute!(:object)
  b << h.form_for(object, role: 'form', html: options_to_html) do |form_builder|
    @form_builder = form_builder
    create_nested_builder(b)
    
    b.form_errors
    build_default_controls(b)
    
    yield if block_given?
    
    render_nested_builder(b)
  end
end