Class: Merb::Helpers::SexyForm::Builder::Base

Inherits:
Form::Builder::ResourcefulFormWithErrors
  • Object
show all
Defined in:
lib/merb-sexy-forms/builder.rb

Instance Method Summary collapse

Instance Method Details

#add_main_container(content, attrs) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/merb-sexy-forms/builder.rb', line 12

def add_main_container(content, attrs)
  ul_options = attrs.delete(:ul)
  if Merb::Plugins.config[:merb_sexy_forms][:container_tag] == "li"
    tag(:ul, content, ul_options)
  else
    content
  end
end

#bound_check_box(method, attrs = {}) {|attrs| ... } ⇒ Object

Yields:

  • (attrs)


51
52
53
54
# File 'lib/merb-sexy-forms/builder.rb', line 51

def bound_check_box(method, attrs = {}, &blk)
  yield(attrs) if block_given?
  super
end

#bound_radio_button(method, attrs = {}) {|attrs| ... } ⇒ Object

Yields:

  • (attrs)


63
64
65
66
# File 'lib/merb-sexy-forms/builder.rb', line 63

def bound_radio_button(method, attrs = {}, &blk)
  yield(attrs) if block_given?
  super
end

#bound_radio_group(method, arr, global_attrs = {}) {|attrs| ... } ⇒ Object

Yields:

  • (attrs)


68
69
70
71
72
# File 'lib/merb-sexy-forms/builder.rb', line 68

def bound_radio_group(method, arr, global_attrs = {})
  yield(attrs) if block_given?
  first = arr.first
  wrap_with_container(global_attrs.merge(:first => first, :method => method), super(method, arr))
end

#bound_select(method, attrs = {}) {|attrs| ... } ⇒ Object

Yields:

  • (attrs)


84
85
86
87
# File 'lib/merb-sexy-forms/builder.rb', line 84

def bound_select(method, attrs = {}, &blk)
  yield(attrs) if block_given?
  super
end

#bound_text_area(method, attrs = {}) {|attrs| ... } ⇒ Object

Yields:

  • (attrs)


95
96
97
98
# File 'lib/merb-sexy-forms/builder.rb', line 95

def bound_text_area(method, attrs = {}, &blk)
  yield(attrs) if block_given?
  super
end

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

Yields:

  • (attrs)


100
101
102
103
# File 'lib/merb-sexy-forms/builder.rb', line 100

def button(contents, attrs = {})
  yield(attrs) if block_given?
  wrap_with_container(attrs, super(contents, clean_args!(attrs)))
end

#form(attrs = {}, &blk) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/merb-sexy-forms/builder.rb', line 4

def form(attrs = {}, &blk)
  add_css_class(attrs, "sexy")
  super(attrs) do
    captured = @origin.capture(&blk)
    add_main_container(captured, attrs)
  end
end

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

Yields:

  • (attrs)


105
106
107
108
# File 'lib/merb-sexy-forms/builder.rb', line 105

def submit(value, attrs = {})
  yield(attrs) if block_given?
  wrap_with_container(attrs, super(value, clean_args!(attrs)))
end

#unbound_check_box(attrs = {}) {|attrs| ... } ⇒ Object

Yields:

  • (attrs)


44
45
46
47
48
49
# File 'lib/merb-sexy-forms/builder.rb', line 44

def unbound_check_box(attrs = {})
  yield(attrs) if block_given?
  update_label_options(attrs, "radio")
  wrap_with_container(attrs.merge(:label => nil),
      super(clean_args!(attrs)))
end

#unbound_radio_button(attrs = {}) {|attrs| ... } ⇒ Object

Yields:

  • (attrs)


56
57
58
59
60
61
# File 'lib/merb-sexy-forms/builder.rb', line 56

def unbound_radio_button(attrs = {})
  yield(attrs) if block_given?
  update_label_options(attrs, "radio")
  wrap_with_container(attrs.merge(:label => nil),
      super(clean_args!(attrs)))
end

#unbound_radio_group(arr, global_attrs = {}) {|attrs| ... } ⇒ Object

Yields:

  • (attrs)


74
75
76
77
# File 'lib/merb-sexy-forms/builder.rb', line 74

def unbound_radio_group(arr, global_attrs = {})
  yield(attrs) if block_given?
  wrap_with_container(global_attrs, super(arr))
end

#unbound_select(attrs = {}) {|attrs| ... } ⇒ Object

Yields:

  • (attrs)


79
80
81
82
# File 'lib/merb-sexy-forms/builder.rb', line 79

def unbound_select(attrs = {})
  yield(attrs) if block_given?
  wrap_with_container(attrs, super(clean_args!(attrs)))
end

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

Yields:

  • (attrs)


89
90
91
92
93
# File 'lib/merb-sexy-forms/builder.rb', line 89

def unbound_text_area(contents, attrs = {})
  yield(attrs) if block_given?
  label = attrs.delete(:label)
  wrap_with_container(attrs.merge(:label => label), super(clean_args!(attrs)))
end

#wrap_with_container(attrs = {}, content = "") ⇒ Object



21
22
23
24
25
26
# File 'lib/merb-sexy-forms/builder.rb', line 21

def wrap_with_container(attrs = {}, content = "")
  content = add_html_to_field(content, attrs)
  content = add_field_wrapper(content, attrs)
  content = add_main_label(content, attrs)
  content = add_container(content, attrs)
end