Class: Showbuilder::Builders::FormBuilder

Inherits:
Object
  • Object
show all
Includes:
TemplateMethods, I18nText
Defined in:
lib/showbuilder/builders/form_builder.rb

Instance Attribute Summary

Attributes included from TemplateMethods

#template

Instance Method Summary collapse

Methods included from I18nText

#show_current_itext, #show_itext

Methods included from TemplateMethods

#method_missing

Constructor Details

#initialize(template) ⇒ FormBuilder

Returns a new instance of FormBuilder.



10
11
12
# File 'lib/showbuilder/builders/form_builder.rb', line 10

def initialize(template)
  @template = template
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Showbuilder::Builders::TemplateMethods

Instance Method Details

#show_current_itext_baseObject



47
48
49
# File 'lib/showbuilder/builders/form_builder.rb', line 47

def show_current_itext_base
  self.controller_name.to_s.singularize + '.form'
end

#show_email_input(method) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/showbuilder/builders/form_builder.rb', line 22

def show_email_input(method)
  self.show_method_shell(method) do
    self.contents_tag(:div, :class => "input-append") do |contents|
      contents << self.email_field_tag(method, nil, :class => 'xlarge', :id => 'xlInput')
      contents << self.(:span, "@", :class => "add-on")
    end
  end
end

#show_method_shell(method) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/showbuilder/builders/form_builder.rb', line 37

def show_method_shell(method)
  self.contents_tag :div, :class => :clearfix do |contents|
    label_text = self.show_current_itext(method)
    contents << self.label(method, label_text)
    contents << self.(:div, :class => :input) do
      yield
    end
  end
end

#show_password_input(method) ⇒ Object



31
32
33
34
35
# File 'lib/showbuilder/builders/form_builder.rb', line 31

def show_password_input(method)
  self.show_method_shell(method) do
    self.password_field_tag(method, nil, :class => 'xlarge', :id => 'xlInput')
  end
end

#show_text_input(method, options = {}) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/showbuilder/builders/form_builder.rb', line 14

def show_text_input(method, options = {})
  options ||={}
  html_options = options[:html]
  self.show_method_shell(method) do
    self.text_field_tag(method, nil, :class => 'xlarge', :id => 'xlInput')
  end
end