Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-78736

$form->get_data() does not call child validation()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 4.1.2
    • Forms Library
    • None
    • MOODLE_401_STABLE

      When using $form->get_data(), it use internal validations which does not call child validation(). It creates problem when you have a required form field with server-side validation using your child validation(). Internal validation will return false with array of error but child validation() cannot override that error. Also the form is already marked with false during internal validation, returning empty error value from child validation() does not create any difference.

      After inspecting the core code, it seems like parent validation() is not performing any internal validation and returning empty array. Whereas in [doc|https://docs.moodle.org/dev/lib/formslib.php_Validation,] its mentioned:

      Also, note that if you decide to override this method in your child class, depending of its hierarchy, you'll need to perform one call to its parent validation() method in order to avoid missing various checks.

      Instead of performing internal validation in validate_defined_fields(), it should perform in parent validation() and return any form errors which can then be overridden by child validation().

            Unassigned Unassigned
            zishanj Zishan Javaid
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.