Class: CustomFormBuilder

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Defined in:
app/helpers/custom_form_builder.rb

Instance Method Summary collapse

Instance Method Details

#append_field(name, *args) ⇒ Object



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'app/helpers/custom_form_builder.rb', line 193

def append_field(name, *args)

	options = args.extract_options!

	options.reverse_merge! :label => name
	label = options[:label]
	options.delete(:label)

	options.reverse_merge! :symbol => "#"
	symbol = options[:symbol]
	options.delete(:symbol)

	@template. :div, :class => "control-group" do
		@template.(:label, label, :class => "control-label") +
		@template.(
			:div,
			@template.(
				:div,
				text_field_original(name, *args << options) +
				@template.(:span, symbol, :class => "add-on"),
				:class => "input-append" 
			), 
			:class => "controls"
		)
	end
end

#check_box(name, *args) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
# File 'app/helpers/custom_form_builder.rb', line 51

def check_box(name, *args)
	options = args.extract_options!

	options.reverse_merge! :class => "span7"
	options.reverse_merge! :label => name
	options.reverse_merge! :include_blank => "(Seleccione por favor)";
	label = options[:label]
	options.delete(:label)

	@template.(:label, super(name, *args) + label, :class => "checkbox")
end

#checkbox_originalObject



5
# File 'app/helpers/custom_form_builder.rb', line 5

alias_method :checkbox_original, :check_box

#custom_file_field(name, *args) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/helpers/custom_form_builder.rb', line 21

def custom_file_field(name, *args)
	options = args.extract_options!

	options.reverse_merge! :class => "span7"
	options.reverse_merge! :label => name
	label = options[:label]
	options.delete(:label)

	@template. :div, :class => "control-group" do
		@template.(:label, label, :class => "control-label") +
		@template.(:div, file_field(name, *args << options), :class => "controls")
	end
end

#date_picker(name, *args) ⇒ Object



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'app/helpers/custom_form_builder.rb', line 128

def date_picker(name, *args)

	options = args.extract_options!

	options.reverse_merge! :value => Time.now.strftime("%d-%m-%Y")
	options.reverse_merge! :label => name
	label = options[:label]
	options.delete(:label)

	@template. :div, :class => "control-group" do
		@template.(:label, label, :class => "control-label") +
		@template.(
			:div, 
			@template.(
				:div,
				text_field_original(name, *args << options) + 
				@template.(
					:span,
					@template.(
						:i,
						nil,
						:class => "icon-th"
					),
					:class => "add-on" 
				),
				{
					:class => "input-append date span5 datepicker datepicker-basic",
					:data => {
						:date_format => "dd-mm-yyyy",
						:date => options[:value]
					}
				}
			), 
			:class => "controls"
		)
	end
end

#number_field(name, *args) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'app/helpers/custom_form_builder.rb', line 78

def number_field(name, *args)
	options = args.extract_options!

	options.reverse_merge! :class => "span5"
	options.reverse_merge! :label => name
	label = options[:label]
	options.delete(:label)

	@template. :div, :class => "control-group" do
		@template.(:label, label, :class => "control-label") +
		@template.(:div, super(name, *args << options), :class => "controls")
	end
end

#password_field(name, *args) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'app/helpers/custom_form_builder.rb', line 92

def password_field(name, *args)
	options = args.extract_options!

	options.reverse_merge! :class => "span7"
	options.reverse_merge! :label => name
	label = options[:label]
	options.delete(:label)

	@template. :div, :class => "control-group" do
		@template.(:label, label, :class => "control-label") +
		@template.(:div, super(name, *args << options), :class => "controls")
	end
end

#prepend_field(name, *args) ⇒ Object



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'app/helpers/custom_form_builder.rb', line 166

def prepend_field(name, *args)

	options = args.extract_options!

	options.reverse_merge! :label => name
	label = options[:label]
	options.delete(:label)

	options.reverse_merge! :symbol => "#"
	symbol = options[:symbol]
	options.delete(:symbol)

	@template. :div, :class => "control-group" do
		@template.(:label, label, :class => "control-label") +
		@template.(
			:div,
			@template.(
				:div,
				@template.(:span, symbol, :class => "add-on") +
				text_field_original(name, *args << options),
				:class => "input-prepend" 
			), 
			:class => "controls"
		)
	end
end

#radio_button_group(name, buttons, options) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/helpers/custom_form_builder.rb', line 35

def radio_button_group(name, buttons, options)

	options.reverse_merge! :label => name
	options.reverse_merge! :html => {}
	output = ""

	buttons.each do |b|
		output += @template.(:label, radio_button_original(name, b, options[:html]) + b.capitalize, :class => "radio")
	end

	@template. :div, :class => "control-group" do
		@template.(:label, options[:label], :class => "control-label") +
		@template.(:div, output, { :class => "controls"}, false)
	end
end

#select(name, select_options, *args) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'app/helpers/custom_form_builder.rb', line 63

def select(name, select_options, *args)
	options = args.extract_options!

	options.reverse_merge! :class => "span7"
	options.reverse_merge! :label => name
	options.reverse_merge! :include_blank => "(Seleccione por favor)";
	label = options[:label]
	options.delete(:label)

	@template. :div, :class => "control-group" do
		@template.(:label, label, :class => "control-label") +
		@template.(:div, super(name, select_options, *args << options), :class => "controls")
	end
end

#submit(name, *args) ⇒ Object



121
122
123
124
125
126
# File 'app/helpers/custom_form_builder.rb', line 121

def submit(name, *args)
	options = args.extract_options!

	options.reverse_merge! :class => "btn btn-primary"
	super(name, *args << options)
end

#text_area(name, *args) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'app/helpers/custom_form_builder.rb', line 106

def text_area(name, *args)
	options = args.extract_options!

	options.reverse_merge! :class => "span7"
	options.reverse_merge! :rows => "10"
	options.reverse_merge! :label => name
	label = options[:label]
	options.delete(:label)

	@template. :div, :class => "control-group" do
		@template.(:label, label, :class => "control-label") +
		@template.(:div, super(name, *args << options), :class => "controls")
	end
end

#text_field(name, *args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/helpers/custom_form_builder.rb', line 7

def text_field(name, *args)
	options = args.extract_options!

	options.reverse_merge! :class => "span7"
	options.reverse_merge! :label => name
	label = options[:label]
	options.delete(:label)

	@template. :div, :class => "control-group" do
		@template.(:label, label, :class => "control-label") +
		@template.(:div, super(name, *args << options), :class => "controls")
	end
end

#text_field_originalObject



3
# File 'app/helpers/custom_form_builder.rb', line 3

alias_method :text_field_original, :text_field