Limit event types lenght
This commit is contained in:
parent
301ad1c722
commit
55c41810b2
4 changed files with 50 additions and 6 deletions
|
|
@ -6,6 +6,18 @@ class EventType < ActiveRecord::Base
|
|||
validates :length, numericality: {greater_than: 0}
|
||||
validates :minimum_abstract_length, presence: true
|
||||
validates :maximum_abstract_length, presence: true
|
||||
validate :length_step
|
||||
|
||||
alias_attribute :name, :title
|
||||
|
||||
LENGTH_STEP = 15
|
||||
|
||||
private
|
||||
|
||||
##
|
||||
# Check if length is multiple of LENGTH_STEP. Used as validation.
|
||||
#
|
||||
def length_step
|
||||
errors.add(:length, "must be multiple of #{LENGTH_STEP}") if length % LENGTH_STEP != 0
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
.col-md-12
|
||||
= semantic_form_for(@event_type, :url => (@event_type.new_record? ? admin_conference_program_event_types_path : admin_conference_program_event_type_path(@conference.short_title, @event_type))) do |f|
|
||||
= f.input :title
|
||||
= f.input :length, :input_html => {:size => 3}
|
||||
= f.input :length, :input_html => {size: 3, type: 'number', step: EventType::LENGTH_STEP, min: EventType::LENGTH_STEP}
|
||||
= f.input :description
|
||||
= f.input :minimum_abstract_length, :input_html => {:size => 3}
|
||||
= f.input :maximum_abstract_length, :input_html => {:size => 3}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue