Class: Bootstrap::Component::HorizontalForm
- Inherits:
-
Form
- Object
- Bootstrap::Component
- Form
- Bootstrap::Component::HorizontalForm
- Defined in:
- mod/bootstrap/lib/bootstrap/component/horizontal_form.rb
Instance Method Summary collapse
-
#checkbox(text, extra_args) ⇒ Object
-
#input(type, label:, id:, &block) ⇒ Object
-
#label_col(label, id:) ⇒ Object
def_div_method :input, nil do opts, extra_args, &block type, label = extra_args prepend { tag(:label, nil, for: opts[:id]) { label } } if label insert { inner_input opts.merge(type: type) } { class: “col-sm-##right_col_width” } end. -
#left_col_width ⇒ Object
-
#right_col_width ⇒ Object
Methods inherited from Form
#form, #group, #label, #render_content
Methods inherited from Bootstrap::Component
#append, def_div_method, def_simple_tag_method, def_tag_method, #initialize, #insert, #prepend, #render, render, #wrap
Methods included from Delegate
#method_missing, #respond_to_missing?
Methods included from BasicTags
Constructor Details
This class inherits a constructor from Bootstrap::Component
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Bootstrap::Delegate
Instance Method Details
#checkbox(text, extra_args) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'mod/bootstrap/lib/bootstrap/component/horizontal_form.rb', line 52 def checkbox text, extra_args @html.div class: "col-sm-offset-#{left_col_width} col-sm-#{right_col_width}" do @html.div class: "checkbox" do label_cllabel do inner_input "checkbox" end end end end |
#input(type, label:, id:, &block) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'mod/bootstrap/lib/bootstrap/component/horizontal_form.rb', line 30 def input type, label:, id:, &block label_col label, id: id @html.div class: "col-sm-#{right_col_width}" do @html.input type: type, id: id, class: "form-control" end # block.call class: "col-sm-#{right_col_width}" do # inner_input opts.merge(type: type) # end end |
#label_col(label, id:) ⇒ Object
def_div_method :input, nil do |opts, extra_args, &block| type, label = extra_args prepend { tag(:label, nil, for: opts[:id]) { label } } if label insert { inner_input opts.merge(type: type) } { class: “col-sm-##right_col_width” } end
26 27 28 |
# File 'mod/bootstrap/lib/bootstrap/component/horizontal_form.rb', line 26 def label_col label, id: @html.label label, for: id, class: "col-sm-#{left_col_width} control-label" end |
#left_col_width ⇒ Object
4 5 6 |
# File 'mod/bootstrap/lib/bootstrap/component/horizontal_form.rb', line 4 def left_col_width @child_args.last && @child_args.last[0] || 2 end |
#right_col_width ⇒ Object
8 9 10 |
# File 'mod/bootstrap/lib/bootstrap/component/horizontal_form.rb', line 8 def right_col_width @child_args.last && @child_args.last[1] || 10 end |