registerNoSubmitButton but NOT skip validation : possible?

Re: registerNoSubmitButton but NOT skip validation : possible?

by Joseph Rézeau -
Number of replies: 0
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Oh well, that last post of mine got me thinking and finally I found a working solution...

I reverted from using the wizard to my original solution of using a NoSubmitButton. Then, from within function definition_inner($mform) I call $this->validation($data,'');

And then I "hi-jacked" this bit of code from question.php:

$moodle_val = $this->validation($data, '');
                if ((is_array($moodle_val) && count($moodle_val)!==0)) {
                    // non-empty array means errors
                    foreach ($moodle_val as $element=>$msg) {
                        $mform->setElementError($element, $msg);
                    }
                    $moodle_val = false;
    
                } else {
                    // anything else means validation ok
                    $moodle_val = true;
                }

... which does exactly what I originally wanted.

Joseph