<label for="custom_field_min_length"><%=l(:label_min_max_length)%></label>
<%= f.text_field :min_length, :size => 5, :no_label => true %> -
<%= f.text_field :max_length, :size => 5, :no_label => true %>
- <em class="info"><%= l(:text_min_max_length_info) %></em>
</p>
<p>
<%= f.text_field :regexp, :size => 50 %>
api.customized_type field.class.customized_class.name.underscore if field.class.customized_class
api.field_format field.field_format
api.regexp field.regexp
- api.min_length (field.min_length == 0 ? nil : field.min_length)
- api.max_length (field.max_length == 0 ? nil : field.max_length)
+ api.min_length field.min_length
+ api.max_length field.max_length
api.is_required field.is_required?
api.is_filter field.is_filter?
api.searchable field.searchable
--- /dev/null
+class RemoveCustomFieldsMinMaxLengthDefaultValues < ActiveRecord::Migration
+ def up
+ change_column :custom_fields, :min_length, :int, :default => nil, :null => true
+ change_column :custom_fields, :max_length, :int, :default => nil, :null => true
+ CustomField.where(:min_length => 0).update_all(:min_length => nil)
+ CustomField.where(:max_length => 0).update_all(:max_length => nil)
+ end
+
+ def self.down
+ CustomField.where(:min_length => nil).update_all(:min_length => 0)
+ CustomField.where(:max_length => nil).update_all(:max_length => 0)
+ change_column :custom_fields, :min_length, :int, :default => 0, :null => false
+ change_column :custom_fields, :max_length, :int, :default => 0, :null => false
+ end
+end
unless custom_field.regexp.blank? or value =~ Regexp.new(custom_field.regexp)
errs << ::I18n.t('activerecord.errors.messages.invalid')
end
- if custom_field.min_length > 0 and value.length < custom_field.min_length
+ if custom_field.min_length && value.length < custom_field.min_length
errs << ::I18n.t('activerecord.errors.messages.too_short', :count => custom_field.min_length)
end
- if custom_field.max_length > 0 and value.length > custom_field.max_length
+ if custom_field.max_length && custom_field.max_length > 0 && value.length > custom_field.max_length
errs << ::I18n.t('activerecord.errors.messages.too_long', :count => custom_field.max_length)
end
end
---
custom_fields_001:
name: Database
- min_length: 0
regexp: ""
is_for_all: true
is_filter: true
type: IssueCustomField
- max_length: 0
possible_values:
- MySQL
- PostgreSQL
position: 1
custom_fields_003:
name: Development status
- min_length: 0
regexp: ""
is_for_all: false
is_filter: true
type: ProjectCustomField
- max_length: 0
possible_values:
- Stable
- Beta
position: 1
custom_fields_004:
name: Phone number
- min_length: 0
regexp: ""
is_for_all: false
type: UserCustomField
- max_length: 0
possible_values: ""
id: 4
is_required: false
position: 1
custom_fields_005:
name: Money
- min_length: 0
regexp: ""
is_for_all: false
type: UserCustomField
- max_length: 0
possible_values: ""
id: 5
is_required: false
position: 2
custom_fields_006:
name: Float field
- min_length: 0
regexp: ""
is_for_all: true
type: IssueCustomField
- max_length: 0
possible_values: ""
id: 6
is_required: false
position: 3
custom_fields_007:
name: Billable
- min_length: 0
regexp: ""
is_for_all: false
is_filter: true
type: TimeEntryActivityCustomField
- max_length: 0
possible_values: ""
id: 7
is_required: false
position: 1
custom_fields_008:
name: Custom date
- min_length: 0
regexp: ""
is_for_all: true
is_filter: false
type: IssueCustomField
- max_length: 0
possible_values: ""
id: 8
is_required: false
position: 4
custom_fields_009:
name: Project 1 cf
- min_length: 0
regexp: ""
is_for_all: false
is_filter: true
type: IssueCustomField
- max_length: 0
possible_values: ""
id: 9
is_required: false
position: 5
custom_fields_010:
name: Overtime
- min_length: 0
regexp: ""
is_for_all: false
is_filter: false
type: TimeEntryCustomField
- max_length: 0
possible_values: ""
id: 10
is_required: false