Sha256: dea2f8eb87826e0ffc96cd32e237f50641e56c81a3a33649a449f95c5b890a08

Contents?: true

Size: 851 Bytes

Versions: 4

Compression:

Stored size: 851 Bytes

Contents

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

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

      def checkbox(name, condition, extras={})
        attrs = { :name => name, :type => "checkbox", :value => "1" }
        attrs.merge!(:checked => condition ? true : nil)
        attrs.merge(extras)
      end

      def notifier_form(notifier)
        haml(notifier.to_haml, :layout => :notifier, :locals => {
          :config => current_project.config_for(notifier),
          :notifier => "#{notifier.to_s.split(/::/).last}",
          :enabled => current_project.notifies?(notifier)
        })
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 4 rubygems

Version Path
brycethornton-integrity-0.1.7.1 lib/integrity/helpers/forms.rb
foca-integrity-0.1.8 lib/integrity/helpers/forms.rb
myronmarston-integrity-0.1.7.1 lib/integrity/helpers/forms.rb
integrity-0.1.8 lib/integrity/helpers/forms.rb