Class: Card::Bootstrap::Component::HorizontalForm
- Inherits:
-
Form
- Object
- Component
- Form
- Card::Bootstrap::Component::HorizontalForm
show all
- Defined in:
- lib/card/bootstrap/component/horizontal_form.rb
Overview
support class for horizontal bootstrap forms
Instance Method Summary
collapse
-
#checkbox(_text, _extra_args) ⇒ Object
-
#input(type, label: nil, id: nil) ⇒ Object
-
#label_col(label, id: nil) ⇒ Object
def_div_method :input, nil do |opts, extra_args, &block| type, label = extra_args prepend { tag(:label, nil, for: opts) { 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
Instance Method Details
#checkbox(_text, _extra_args) ⇒ Object
54
55
56
57
58
59
60
61
62
|
# File 'lib/card/bootstrap/component/horizontal_form.rb', line 54
def checkbox _text,
@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
|
32
33
34
35
36
37
38
39
40
|
# File 'lib/card/bootstrap/component/horizontal_form.rb', line 32
def input type, label: nil, id: nil
label_col label, id: id
@html.div class: "col-sm-#{right_col_width}" do
@html.input type: type, id: id, class: "form-control"
end
end
|
#label_col(label, id: nil) ⇒ Object
def_div_method :input, nil do |opts, extra_args, &block|
type, label = extra_args
prepend { tag(:label, nil, for: opts) { label } } if label
insert { inner_input opts.merge(type: type) }
{ class: "col-sm-##right_col_width" }
end
28
29
30
|
# File 'lib/card/bootstrap/component/horizontal_form.rb', line 28
def label_col label, id: nil
@html.label label, for: id, class: "col-sm-#{left_col_width} control-label"
end
|
#left_col_width ⇒ Object
6
7
8
|
# File 'lib/card/bootstrap/component/horizontal_form.rb', line 6
def left_col_width
(@child_args.last && @child_args.last[0]) || 2
end
|
#right_col_width ⇒ Object
10
11
12
|
# File 'lib/card/bootstrap/component/horizontal_form.rb', line 10
def right_col_width
(@child_args.last && @child_args.last[1]) || 10
end
|