Class: Interview::Form
- Includes:
- HasControls
- Defined in:
- lib/interview/form.rb
Instance Attribute Summary collapse
-
#align ⇒ Object
Returns the value of attribute align.
-
#form_builder ⇒ Object
readonly
Returns the value of attribute form_builder.
-
#multi_create ⇒ Object
Returns the value of attribute multi_create.
-
#redirect_to ⇒ Object
Returns the value of attribute redirect_to.
-
#skip_submit ⇒ Object
Returns the value of attribute skip_submit.
Attributes included from HasControls
Attributes inherited from Control
Instance Method Summary collapse
Methods included from HasControls
#add_control, #add_controls, included, #initialize, #siblings
Methods inherited from Control
#ancestors, build, definition, #find_attribute, #find_attribute!, inherited, #initialize, #set_attributes, #set_defaults
Instance Attribute Details
#align ⇒ Object
Returns the value of attribute align.
5 6 7 |
# File 'lib/interview/form.rb', line 5 def align @align end |
#form_builder ⇒ Object (readonly)
Returns the value of attribute form_builder.
6 7 8 |
# File 'lib/interview/form.rb', line 6 def form_builder @form_builder end |
#multi_create ⇒ Object
Returns the value of attribute multi_create.
5 6 7 |
# File 'lib/interview/form.rb', line 5 def multi_create @multi_create end |
#redirect_to ⇒ Object
Returns the value of attribute redirect_to.
5 6 7 |
# File 'lib/interview/form.rb', line 5 def redirect_to @redirect_to end |
#skip_submit ⇒ Object
Returns the value of attribute skip_submit.
5 6 7 |
# File 'lib/interview/form.rb', line 5 def skip_submit @skip_submit end |
Instance Method Details
#render ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/interview/form.rb', line 8 def render object = find_attribute!(:object) = case @align when 'horizontal' then { class: 'form-horizontal' } when 'inline' then { class: 'form-inline' } else {} end return h.form_for(object, role: 'form', html: ) do |form_builder| @form_builder = form_builder html = Builder::XmlMarkup.new(indent: 2) render_default_controls(html) @controls.each do |control| html << control.render html.text! ' ' if @align == 'inline' end if @align == 'horizontal' html.div class: 'form-group' do html.div class: 'col-sm-offset-3 col-sm-9' do render_submit(html) end end else render_submit(html) end html.target!.html_safe end end |