Class: Card::Bootstrap::Component::Form
- Inherits:
-
Card::Bootstrap::Component
- Object
- Card::Bootstrap::Component
- Card::Bootstrap::Component::Form
- Defined in:
- mod/bootstrap/lib/card/bootstrap/component/form.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#form(opts = {}, &block) ⇒ Object
def_tag_method :form, nil, optional_classes: { horizontal: “form-horizontal”, inline: “form-inline” } def_div_method :group, “form-group” def_tag_method :label, nil def_tag_method :input, “form-control” do opts, extra_args type, label = extra_args prepend { label label, for: opts[:id] } if label opts[:type] = type opts end. -
#group(text = nil, &block) ⇒ Object
-
#input(type, text: nil, label: nil, id: nil) ⇒ Object
-
#label(text = nil, &block) ⇒ Object
-
#render_content(*args) ⇒ Object
Methods inherited from Card::Bootstrap::Component
#append, #card, #initialize, #insert, #prepend, #render, #wrap
Methods included from Card::Bootstrap::ComponentKlass
#def_div_method, #def_tag_method, #render
Methods included from Delegate
#method_missing, #respond_to_missing?
Methods included from BasicTags
Constructor Details
This class inherits a constructor from Card::Bootstrap::Component
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Card::Bootstrap::Delegate
Instance Method Details
#form(opts = {}, &block) ⇒ Object
def_tag_method :form, nil, optional_classes: { horizontal: “form-horizontal”, inline: “form-inline” } def_div_method :group, “form-group” def_tag_method :label, nil def_tag_method :input, “form-control” do |opts, extra_args| type, label = extra_args prepend { label label, for: opts[:id] } if label opts[:type] = type opts end
23 24 25 26 27 28 29 |
# File 'mod/bootstrap/lib/card/bootstrap/component/form.rb', line 23 def form opts={}, &block add_class opts, "form-horizontal" if opts.delete(:horizontal) add_class opts, "form-inline" if opts.delete(:inline) @html.form opts do instance_exec(&block) end end |
#group(text = nil, &block) ⇒ Object
31 32 33 34 35 |
# File 'mod/bootstrap/lib/card/bootstrap/component/form.rb', line 31 def group text=nil, &block @html.div text, class: "form-group" do instance_exec(&block) end end |
#input(type, text: nil, label: nil, id: nil) ⇒ Object
41 42 43 44 45 46 |
# File 'mod/bootstrap/lib/card/bootstrap/component/form.rb', line 41 def input type, text: nil, label: nil, id: nil @html.input id: id, class: "form-control", type: type do @html.label label, for: id if label @html << text if text end end |
#label(text = nil, &block) ⇒ Object
37 38 39 |
# File 'mod/bootstrap/lib/card/bootstrap/component/form.rb', line 37 def label text=nil, &block @html.label text, &block end |
#render_content(*args) ⇒ Object
5 6 7 |
# File 'mod/bootstrap/lib/card/bootstrap/component/form.rb', line 5 def render_content *args form(*args, &@build_block) end |