Class: TwitterBootstrapBuilder::Builders::FieldsetBuilder

Inherits:
Base
  • Object
show all
Defined in:
lib/twitter_bootstrap_builder/builders/fieldset_builder.rb

Instance Attribute Summary

Attributes inherited from Base

#block, #options, #template

Instance Method Summary collapse

Methods inherited from Base

#html_safe, #initialize

Constructor Details

This class inherits a constructor from TwitterBootstrapBuilder::Builders::Base

Instance Method Details

#actions(&block) ⇒ Object



19
20
21
22
23
# File 'lib/twitter_bootstrap_builder/builders/fieldset_builder.rb', line 19

def actions(&block)
  actions = Tag.block(:div, class: 'form-actions')
  actions.append template.capture(self, &block) if block
  actions.html_safe
end

#check_box(method, options = {}) ⇒ Object



73
74
75
76
77
# File 'lib/twitter_bootstrap_builder/builders/fieldset_builder.rb', line 73

def check_box(method, options={})
  ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
    cg.append form_builder.check_box(method, options)
  end.html_safe
end

#custom_field(label, options = {}, &block) ⇒ Object



109
110
111
112
113
# File 'lib/twitter_bootstrap_builder/builders/fieldset_builder.rb', line 109

def custom_field(label, options={}, &block)
  ControlGroup.new(label, options) do |cg|
    cg.append template.capture(self, &block) if block
  end.html_safe
end

#date_select(method, options = {}, html_options = {}) ⇒ Object



91
92
93
94
95
# File 'lib/twitter_bootstrap_builder/builders/fieldset_builder.rb', line 91

def date_select(method, options={}, html_options={})
  ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
    cg.append form_builder.date_select(method, form_builder.send('objectify_options', options), html_options)
  end.html_safe
end

#datetime_select(method, options = {}, html_options = {}) ⇒ Object



103
104
105
106
107
# File 'lib/twitter_bootstrap_builder/builders/fieldset_builder.rb', line 103

def datetime_select(method, options={}, html_options={})
  ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
    cg.append form_builder.datetime_select(method, form_builder.send('objectify_options', options), html_options)
  end.html_safe
end

#display_field(method, options = {}) ⇒ Object



25
26
27
28
29
# File 'lib/twitter_bootstrap_builder/builders/fieldset_builder.rb', line 25

def display_field(method, options={})
  ControlGroup.new(options[:label] || model.class.human_attribute_name(method)) do |cg|
    cg.append Tag.block(:span, model.send(method).to_s.gsub("\n", '<br>'), class: 'display')
  end.html_safe
end

#email_field(method, options = {}) ⇒ Object



61
62
63
64
65
# File 'lib/twitter_bootstrap_builder/builders/fieldset_builder.rb', line 61

def email_field(method, options={})
  ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
    cg.append form_builder.email_field(method, options)
  end.html_safe
end

#form_builderObject



11
12
13
# File 'lib/twitter_bootstrap_builder/builders/fieldset_builder.rb', line 11

def form_builder
  options[:form_builder]
end

#hidden_field(method, options = {}) ⇒ Object



79
80
81
82
83
# File 'lib/twitter_bootstrap_builder/builders/fieldset_builder.rb', line 79

def hidden_field(method, options={})
  ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
    cg.append form_builder.hidden_field(method, options)
  end.html_safe
end

#modelObject



15
16
17
# File 'lib/twitter_bootstrap_builder/builders/fieldset_builder.rb', line 15

def model
  options[:model] || form_builder.object
end

#password_field(method, options = {}) ⇒ Object



67
68
69
70
71
# File 'lib/twitter_bootstrap_builder/builders/fieldset_builder.rb', line 67

def password_field(method, options={})
  ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
    cg.append form_builder.password_field(method, options)
  end.html_safe
end

#select(method, choices, options = {}, html_options = {}) ⇒ Object



85
86
87
88
89
# File 'lib/twitter_bootstrap_builder/builders/fieldset_builder.rb', line 85

def select(method, choices, options={}, html_options={})
  ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
    cg.append form_builder.select(method, choices, options, html_options)
  end.html_safe
end

#text_area(method, options = {}) ⇒ Object



46
47
48
49
50
# File 'lib/twitter_bootstrap_builder/builders/fieldset_builder.rb', line 46

def text_area(method, options={})
  ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
    cg.append form_builder.text_area(method, options)
  end.html_safe
end

#text_field(method, options = {}) ⇒ Object



31
32
33
34
35
# File 'lib/twitter_bootstrap_builder/builders/fieldset_builder.rb', line 31

def text_field(method, options={})
  ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
    cg.append form_builder.text_field(method, options)
  end.html_safe
end

#time_select(method, options = {}, html_options = {}) ⇒ Object



97
98
99
100
101
# File 'lib/twitter_bootstrap_builder/builders/fieldset_builder.rb', line 97

def time_select(method, options={}, html_options={})
  ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
    cg.append form_builder.time_select(method, form_builder.send('objectify_options', options), html_options)
  end.html_safe
end

#to_sObject



5
6
7
8
9
# File 'lib/twitter_bootstrap_builder/builders/fieldset_builder.rb', line 5

def to_s
  fieldset = Tag.block(:fieldset, class: 'form-horizontal')
  fieldset.append template.capture(self, &block) if block
  fieldset.to_s
end