Sha256: 75bfd2e289a8d2f81b7bb5e47458383c6e78adb953ff4eee0f3e224798c06fbc

Contents?: true

Size: 860 Bytes

Versions: 6

Compression:

Stored size: 860 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[:checked] = !!condition
        attrs.update(extras)
      end

      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
    end
  end
end

Version data entries

6 entries across 6 versions & 4 rubygems

Version Path
foca-integrity-0.1.9.3 lib/integrity/helpers/forms.rb
gforces-integrity-0.1.9.3 lib/integrity/helpers/forms.rb
gforces-integrity-0.1.9.4 lib/integrity/helpers/forms.rb
imbriaco-integrity-0.1.9.2.1 lib/integrity/helpers/forms.rb
imbriaco-integrity-0.1.9.2 lib/integrity/helpers/forms.rb
integrity-0.1.9.3 lib/integrity/helpers/forms.rb