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

Inherits:
Base show all
Defined in:
merb-helpers/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

- (Object) button(contents, attrs = {})



366
367
368
# File 'merb-helpers/lib/merb-helpers/form/builder.rb', line 366

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

- (Object) label(contents, attrs = {})



304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'merb-helpers/lib/merb-helpers/form/builder.rb', line 304

def label(contents, attrs = {})
  if contents
    if contents.is_a?(Hash)
      label_attrs = contents
      contents = label_attrs.delete(:title)
    else
      label_attrs = attrs
    end
    tag(:label, contents, label_attrs)
  else
    ""
  end
end

- (Object) submit(value, attrs = {})



370
371
372
# File 'merb-helpers/lib/merb-helpers/form/builder.rb', line 370

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

- (Object) unbound_check_box(attrs = {})



343
344
345
346
# File 'merb-helpers/lib/merb-helpers/form/builder.rb', line 343

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

- (Object) unbound_hidden_field(attrs = {})



348
349
350
351
# File 'merb-helpers/lib/merb-helpers/form/builder.rb', line 348

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

- (Object) unbound_label(attrs = {})



326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'merb-helpers/lib/merb-helpers/form/builder.rb', line 326

def unbound_label(attrs = {})
  if attrs[:id]
    label_attrs = {:for => attrs[:id]}
  elsif attrs[:name]
    label_attrs = {:for => attrs[:name]}
  else
    label_attrs = {}
  end

  label_option = attrs.delete(:label)
  if label_option.is_a? Hash
    label(label_attrs.merge(label_option))
  else
    label(label_option, label_attrs)
  end
end

- (Object) unbound_radio_button(attrs = {})



353
354
355
356
# File 'merb-helpers/lib/merb-helpers/form/builder.rb', line 353

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

- (Object) unbound_select(attrs = {})



358
359
360
# File 'merb-helpers/lib/merb-helpers/form/builder.rb', line 358

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

- (Object) unbound_text_area(contents, attrs = {})



362
363
364
# File 'merb-helpers/lib/merb-helpers/form/builder.rb', line 362

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