Class: Merb::Helpers::Form::Builder::Form

Inherits:
Base
  • Object
show all
Defined in:
lib/merb-helpers/form/builder.rb

Direct Known Subclasses

FormWithErrors, ResourcefulForm

Instance Method Summary collapse

Methods inherited from Base

#bound_check_box, #bound_radio_button, #bound_radio_group, #bound_select, #bound_text_area, #fieldset, #form, #initialize, #unbound_radio_group

Methods included from Tag

#close_tag, #open_tag, #self_closing_tag, #tag

Constructor Details

This class inherits a constructor from Merb::Helpers::Form::Builder::Base

Instance Method Details

#button(contents, attrs = {}) ⇒ Object



332
333
334
# File 'lib/merb-helpers/form/builder.rb', line 332

def button(contents, attrs = {})
  label(attrs) + super
end

#label(contents, attrs = {}) ⇒ Object



283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/merb-helpers/form/builder.rb', line 283

def label(contents, attrs = {})
  if contents.is_a?(Hash)
    attrs    = contents
    contents = attrs.delete(:label)
  end
  if contents
    for_attr = attrs[:id] ? {:for => attrs[:id]} : {}
    if contents.is_a?(Hash)
      attrs = contents
      contents = attrs.delete(:title)
      for_attr = for_attr.merge(attrs)
    end
    tag(:label, contents, for_attr)
  else
    ""
  end
end

#submit(value, attrs = {}) ⇒ Object



336
337
338
# File 'lib/merb-helpers/form/builder.rb', line 336

def submit(value, attrs = {})
  label(attrs) + super
end

#unbound_check_box(attrs = {}) ⇒ Object



309
310
311
312
# File 'lib/merb-helpers/form/builder.rb', line 309

def unbound_check_box(attrs = {})
  label_text = label(attrs)
  super + label_text
end

#unbound_hidden_field(attrs = {}) ⇒ Object



314
315
316
317
# File 'lib/merb-helpers/form/builder.rb', line 314

def unbound_hidden_field(attrs = {})
  attrs.delete(:label)
  super
end

#unbound_radio_button(attrs = {}) ⇒ Object



319
320
321
322
# File 'lib/merb-helpers/form/builder.rb', line 319

def unbound_radio_button(attrs = {})
  label_text = label(attrs)
  super + label_text
end

#unbound_select(attrs = {}) ⇒ Object



324
325
326
# File 'lib/merb-helpers/form/builder.rb', line 324

def unbound_select(attrs = {})
  label(attrs) + super
end

#unbound_text_area(contents, attrs = {}) ⇒ Object



328
329
330
# File 'lib/merb-helpers/form/builder.rb', line 328

def unbound_text_area(contents, attrs = {})
  label(attrs) + super
end