Sterc / FormIt

A dynamic form processing Snippet for MODX Revolution
https://docs.modx.com/current/en/extras/formit
33 stars 58 forks source link

$customProperties are processed wrong and $errors never forwarded in Hook class #254

Open arjen-t opened 3 years ago

arjen-t commented 3 years ago

Bug report

Summary

When hooks get called in the request class (runPreHooks, runRenderHooks etc), the sumbitVar and hook names are passed as $customProperties to the loadMultiple method of the Hook class. The implementation of loadMultiple method passes the $customProperties as $errors to the load method. Secondly the $errors of the loadMultiple method are never forwarded to the load method.

Step to reproduce

See implementation of loadMultiple method: https://github.com/Sterc/FormIt/blob/de51f81a0b7e5c90aee3889d6a5a912e4c407a6d/core/components/formit/src/FormIt/Hook.php#L106

and the interface of load method: https://github.com/Sterc/FormIt/blob/de51f81a0b7e5c90aee3889d6a5a912e4c407a6d/core/components/formit/src/FormIt/Hook.php#L127

Observed behavior

Variables are mixed in the loadMultiple method

Expected behavior

$customProperties in loadMultiple method should be passed as $customProperties to the load method. And $errors in loadMultiple method should be forwarded to the load method.

Implementation in loadMultiple method should be as followed:

$success = $this->load($hook, $this->fields, $errors, $customProperties);

Environment

N/A