Sha256: 62cb45d35163b94246eebdf03fabd6ced9e9ce28b38f2645e1731c2e273988d7

Contents?: true

Size: 858 Bytes

Versions: 2

Compression:

Stored size: 858 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(condition ? { :checked => "checked" } : {})
        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

2 entries across 2 versions & 1 rubygems

Version Path
foca-integrity-0.1.6 lib/integrity/helpers/forms.rb
foca-integrity-0.1.7 lib/integrity/helpers/forms.rb