예제 #1
0
 def get_field_errors(self, bound_field):
     """
     Determine the kind of input field and create a list of potential errors which may occur
     during validation of that field. This list is returned to be displayed in '$dirty' state
     if the field does not validate for that criteria.
     """
     errors = super(NgFormValidationMixin,
                    self).get_field_errors(bound_field)
     if bound_field.is_hidden:
         return errors
     identifier = format_html('{0}.{1}', self.form_name,
                              self.add_prefix(bound_field.name))
     errors_function = '{0}_angular_errors'.format(
         bound_field.field.__class__.__name__)
     try:
         errors_function = getattr(VALIDATION_MAPPING_MODULE,
                                   errors_function)
         potential_errors = types.MethodType(errors_function,
                                             bound_field.field)()
     except (TypeError, AttributeError):
         errors_function = getattr(VALIDATION_MAPPING_MODULE,
                                   'Default_angular_errors')
         potential_errors = types.MethodType(errors_function,
                                             bound_field.field)()
     errors.append(
         SafeTuple((identifier, self.field_error_css_classes, '$dirty',
                    '$valid', 'valid', '')))  # for valid fields
     errors.extend([
         SafeTuple((identifier, self.field_error_css_classes, '$dirty',
                    pe[0], 'invalid', force_text(pe[1])))
         for pe in potential_errors
     ])
     return errors
예제 #2
0
 def get_field_errors(self, field):
     errors = super(NgModelFormMixin, self).get_field_errors(field)
     if field.is_hidden:
         return errors
     identifier = format_html('{0}.{1}', self.form_name, field.name)
     errors.append(SafeTuple((identifier, self.field_error_css_classes, '$pristine', '$message', 'invalid', '$message')))
     return errors
예제 #3
0
 def non_field_errors(self):
     errors = super(NgModelFormMixin, self).non_field_errors()
     errors.append(
         SafeTuple((self.form_name, self.form_error_css_classes,
                    '$pristine', '$message', 'invalid', '$message')))
     return errors