Class: Showbuilder::Builders::ModelFormBuilder

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Includes:
TemplateMethods, I18nText
Defined in:
lib/showbuilder/builders/model_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

Dynamic Method Handling

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

Instance Method Details

#show_email_input(method) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/showbuilder/builders/model_form_builder.rb', line 27

def show_email_input(method)
  self.show_method_shell(method) do
    self.contents_tag(:div, :class => "input-append") do |contents|
      contents << self.email_field(method)
      contents << self.(:span, :class => "add-on") do
        (:i, '', :class =>"icon-envelope")
      end
    end
  end
end

#show_memo_input(method) ⇒ Object



44
45
46
47
48
# File 'lib/showbuilder/builders/model_form_builder.rb', line 44

def show_memo_input(method)
  self.show_method_shell(method) do
    self.text_area(method, :rows => 5)
  end
end

#show_method_shell(method, options = {}, &block) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/showbuilder/builders/model_form_builder.rb', line 61

def show_method_shell(method, options = {}, &block)
  options ||= {}

  shell_options   = options[:shell] || {}
  label_options   = options[:shell_label] || {}
  label_content   = options[:shell_title] || show_current_itext(method)
  control_options = options[:shell_control] || {}

  shell_options[:class]   = merge_class_option(shell_options[:class], 'control-group')
  shell_options[:class]   = merge_class_option(shell_options[:class], 'error') if is_object_method_error(method)
  label_options[:class]   = merge_class_option(label_options[:class], 'control-label')
  control_options[:class] = merge_class_option(control_options[:class], 'controls')

  contents_tag :div, shell_options do |contents|
    contents << label(method, label_content, label_options)
    contents << contents_tag(:div, control_options, &block)
  end
end

#show_password_input(method) ⇒ Object



38
39
40
41
42
# File 'lib/showbuilder/builders/model_form_builder.rb', line 38

def show_password_input(method)
  self.show_method_shell(method) do
    self.password_field(method)
  end
end

#show_select_input(method, choices, options = {}) ⇒ Object



50
51
52
53
54
55
56
57
58
59
# File 'lib/showbuilder/builders/model_form_builder.rb', line 50

def show_select_input(method, choices, options = {})
  options ||= {}

  select_options      = options[:select]      || {}
  select_html_options = options[:select_html] || {}

  show_method_shell method, options do
    select method, choices, select_options, select_html_options
  end
end

#show_text_field(method) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/showbuilder/builders/model_form_builder.rb', line 19

def show_text_field(method)
  text = @object.send(method)

  self.show_method_shell(method) do
    self.(:span, text, :class => "uneditable-input")
  end
end

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



10
11
12
13
14
15
16
17
# File 'lib/showbuilder/builders/model_form_builder.rb', line 10

def show_text_input(method, options = {})
  options ||= {}
  input_options = options[:input] || {}

  self.show_method_shell(method, options) do
    self.text_field(method, input_options)
  end
end