Sha256: e6ba1639efac164dd43a8028ef92cbf41426d120a9fbd3a4b55bb7621cb77921
Contents?: true
Size: 852 Bytes
Versions: 28
Compression:
Stored size: 852 Bytes
Contents
module CustomAttributes class DateFieldType < Unbounded include Singleton def cast_single_value(_custom_field, value, _customized = nil) value.to_date rescue nil end def validate_single_value(_custom_field, value, _customizable = nil) if value =~ /^\d{4}-\d{2}-\d{2}$/ && (begin value.to_date rescue false end) [] else [::I18n.t('activerecord.errors.messages.not_a_date')] end end def edit_tag(view, tag_id, tag_name, custom_value, options = {}) view.date_field_tag(tag_name, custom_value.value, options.merge(id: tag_id, size: 10)) + view.calendar_for(tag_id) end end end
Version data entries
28 entries across 28 versions & 1 rubygems