204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
# File 'lib/form_assistant/form_builder.rb', line 204
def self.assist(helper_name)
define_method(helper_name) do |field, *args|
options = (helper_name == 'check_box' ? args.shift : args.) || {}
label_options = (field, options)
template_options = (helper_name, options)
= options.delete(:locals) || {}
label = label_options[:label] === false ? nil : self.label(field, label_options.delete(:text), label_options)
tip = options.delete(:tip)
required = !!options.delete(:required)
field_options = options.except(:label, :template, :tip, :required)
super_args = helper_name == 'check_box' ? args.unshift(field_options) : args.push(field_options)
element = super(field, *super_args)
return element if template_options[:template] === false
return render_element(element, field, helper_name, options, label_options[:label] === false) if self.class.ignore_templates
render_partial_for(element, field, label, tip, template_options[:template], helper_name, required, , args)
end
end
|