class RacingOnRails::FormBuilder

Label + form fields HTML. Wrap checkboxes in divs (probably should do this for all label + field chunks).

Public Instance Methods

labelled_check_box(method, text = nil, check_box_options = {}) click to toggle source

Set editable to false for read-only

# File app/helpers/racing_on_rails/form_builder.rb, line 36
def labelled_check_box(method, text = nil, check_box_options = {})
  label_options = check_box_options.delete(:label) || {}
  if check_box_options[:editable] == false
    %Q{#{label(method, "#{text || method.to_s.titleize}", label_options)} <div class="labelled" id="#{object_name}_#{method}">#{@object.send(method)}</div>}.html_safe
  else
    %Q{<div class="check_box"><div class="input">#{check_box(method, check_box_options)}</div><div  class="label">#{label(method, text || method.to_s.titleize)}</div></div>}.html_safe
  end
end
labelled_country_select(method, options = {}) click to toggle source

List from Countries::COUNTRIES

# File app/helpers/racing_on_rails/form_builder.rb, line 26
def labelled_country_select(method, options = {})
  labelled_select method, RacingAssociation.current.priority_country_options + Countries::COUNTRIES, options.merge(:label => { :text => "Country" })
end
labelled_password_field(method, text = method.to_s.titleize, password_field_options = {}) click to toggle source
# File app/helpers/racing_on_rails/form_builder.rb, line 30
def labelled_password_field(method, text = method.to_s.titleize, password_field_options = {})
  label_options = password_field_options.delete(:label) || {}
  %Q{#{label(method, "#{text}", label_options)} #{password_field(method, password_field_options)}}.html_safe
end
labelled_radio_button(method, value, text = nil) click to toggle source
# File app/helpers/racing_on_rails/form_builder.rb, line 45
def labelled_radio_button(method, value, text = nil)
  %Q{<div class="radio">#{radio_button(method, value)}#{label(method, text || method.to_s.titleize)}</div>}.html_safe
end
labelled_select(method, select_options, options = {}) click to toggle source

Set editable to false for read-only

# File app/helpers/racing_on_rails/form_builder.rb, line 15
def labelled_select(method, select_options, options = {})
  label_options = options.delete(:label) || {}
  text = label_options.delete(:text) if label_options
  if options[:editable] == false
    %Q{#{label(method, "#{text || method.to_s.titleize}", label_options)} <div class="labelled" id="#{object_name}_#{method}">#{@object.send(method)}</div>}.html_safe
  else
    %Q{#{label(method, "#{text || method.to_s.titleize}", label_options)} #{select(method, select_options, options)}}.html_safe
  end
end
labelled_text(method, text = nil, label_text = nil, label_options = {}) click to toggle source
# File app/helpers/racing_on_rails/form_builder.rb, line 60
def labelled_text(method, text = nil, label_text = nil, label_options = {})
  %Q{#{label(method, "#{label_text || method.to_s.titleize}", label_options)} <div class="labelled" id="#{object_name}_#{method}">#{text || @object.send(method)}</div>}.html_safe
end
labelled_text_area(method, options = {}) click to toggle source

Set editable to false for read-only

# File app/helpers/racing_on_rails/form_builder.rb, line 50
def labelled_text_area(method, options = {})
  label_options = options.delete(:label) || {}
  text = label_options[:text] if label_options
  if options[:editable] == false
    %Q{#{label(method, "#{text || method.to_s.titleize}", :class => 'text_area')} <div class="labelled" id="#{object_name}_#{method}">#{@object.send(method)}</div>}.html_safe
  else
    %Q{#{label(method, "#{text || method.to_s.titleize}", :class => 'text_area')}#{text_area(method, options)}}.html_safe
  end
end
labelled_text_field(method, text = method.to_s.titleize, text_field_options = {}) click to toggle source

Set editable to false for read-only

# File app/helpers/racing_on_rails/form_builder.rb, line 5
def labelled_text_field(method, text = method.to_s.titleize, text_field_options = {})
  label_options = text_field_options.delete(:label) || {}
  if text_field_options[:editable] == false
    %Q{#{label(method, "#{text || method.to_s.titleize}", label_options)} <div class="labelled" id="#{object_name}_#{method}">#{@object.send(method)}</div>}.html_safe
  else
    %Q{#{label(method, "#{text || method.to_s.titleize}", label_options)} #{text_field(method, text_field_options)}}.html_safe
  end
end