Class: ParsleySimpleForm::Constraints::Basics::EqualtoConstraint

Inherits:
ParsleySimpleForm::Constraints::BaseConstraint show all
Defined in:
lib/parsley_simple_form/constraints/basics/equalto_constraint.rb

Instance Method Summary collapse

Methods inherited from ParsleySimpleForm::Constraints::BaseConstraint

#initialize, #input_id, #input_type

Constructor Details

This class inherits a constructor from ParsleySimpleForm::Constraints::BaseConstraint

Instance Method Details

#html_attributesObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/parsley_simple_form/constraints/basics/equalto_constraint.rb', line 11

def html_attributes
  return {} if @options.nil? || @options[:equalto].nil?

  attr_equalto = @options[:equalto]      
  input = @form_builder.find_input(attr_equalto, @options, &@block)
  {
    :'data-parsley-equalto' => '#' + input_id(attr_equalto, @options, &@block), 
    :'data-parsley-equalto-message' => 
      I18n::translate('form_validation.message.equalto', field_name: input.object.class.human_attribute_name(input.attribute_name))
  }
end

#match?Boolean

check for :equalto option

Returns:

  • (Boolean)


7
8
9
# File 'lib/parsley_simple_form/constraints/basics/equalto_constraint.rb', line 7

def match?
  !@options[:equalto].nil?
end