Module: Fidelity::FormHelper

Defined in:
app/fidelity/widgets/form/helpers/form_helper.rb

Instance Method Summary collapse

Instance Method Details

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



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/fidelity/widgets/form/helpers/form_helper.rb', line 23

def form_field_with_error options={}, &block
  if block_given?
    if options[:error]
      content = ''.html_safe.tap do |output|
        capture do
          output << yield
          output << (:small, options[:error])
        end        
      end
      (:div, content, :class => 'form-field error')
    else
      (:div, :class => 'form-field') do
        yield
      end
    end
  end
end

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



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/fidelity/widgets/form/helpers/form_helper.rb', line 4

def with_label options={}, &block
  uid = "uid_#{options.object_id}"
  label = if options[:label]
    (:label, options[:label], :for => uid)
  else
    ''
  end
  if block_given?
    ''.html_safe.tap do |output|
      capture do
        output << label
        output << yield(uid)
      end        
    end
  else
    label
  end
end