Sha256: 6106c1ebab130a87d4b8abf736ee4ef643163712c07550cded9ed700c8cc3a0c
Contents?: true
Size: 964 Bytes
Versions: 9
Compression:
Stored size: 964 Bytes
Contents
# Self-marking required fields http://davidsulc.com/blog/2011/05/01/self-marking-required-fields-in-rails-3/ # It works, but I'm leaving it commented. It affects all forms in refinery app, not only in this gem =begin class ActionView::Helpers::FormBuilder alias :orig_label :label # add a '*' after the field label if the field is required def label(method, content_or_options = nil, options = nil, &block) if content_or_options && content_or_options.class == Hash options = content_or_options else content = content_or_options end required_mark = '' required_mark = ' *'.html_safe if object.class.validators_on(method).map(&:class).include? ActiveModel::Validations::PresenceValidator content ||= I18n.t("activerecord.attributes.#{object.class.name.underscore}.#{method}", :default=>method.to_s.humanize) content = content + required_mark self.orig_label(method, content, options || {}, &block) end end =end
Version data entries
9 entries across 9 versions & 2 rubygems