Module: Integrity::Helpers::Forms

Included in:
Integrity::Helpers
Defined in:
lib/integrity/helpers/forms.rb

Instance Method Summary collapse

Instance Method Details

#checkbox(name, condition, extras = {}) ⇒ Object



13
14
15
16
17
# File 'lib/integrity/helpers/forms.rb', line 13

def checkbox(name, condition, extras={})
  attrs = { :name => name, :type => "checkbox", :value => "1" }
  attrs[:checked] = !!condition
  attrs.update(extras)
end

#error_class(object, field) ⇒ Object



9
10
11
# File 'lib/integrity/helpers/forms.rb', line 9

def error_class(object, field)
  object.errors.on(field).nil? ? "" : "with_errors"
end

#errors_on(object, field) ⇒ Object



4
5
6
7
# File 'lib/integrity/helpers/forms.rb', line 4

def errors_on(object, field)
  return "" unless errors = object.errors.on(field)
  errors.map {|e| e.gsub(/#{field} /i, "") }.join(", ")
end

#notifier_formObject



19
20
21
22
23
24
25
26
# File 'lib/integrity/helpers/forms.rb', line 19

def notifier_form
  Notifier.available.each_pair { |name, klass|
    haml_concat haml(klass.to_haml, :layout => :notifier, :locals => {
      :notifier => name,
      :enabled  => current_project.notifies?(name),
      :config   => current_project.config_for(name) })
  }
end