From 21e9c5bc3356f3b395976fbdf2f0aa064fc4bb75 Mon Sep 17 00:00:00 2001 From: Ahmet <71610210+ayrzDev@users.noreply.github.com> Date: Sun, 5 Nov 2023 13:09:49 +0300 Subject: [PATCH 1/2] Update ModalForm.php The error related to the "Esc" key has been fixed --- src/jojoe77777/FormAPI/ModalForm.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/jojoe77777/FormAPI/ModalForm.php b/src/jojoe77777/FormAPI/ModalForm.php index 3f46c92..9ee0fa4 100755 --- a/src/jojoe77777/FormAPI/ModalForm.php +++ b/src/jojoe77777/FormAPI/ModalForm.php @@ -23,9 +23,24 @@ public function __construct(?callable $callable) { $this->data["button2"] = ""; } - public function processData(&$data) : void { - if(!is_bool($data)) { - throw new FormValidationException("Expected a boolean response, got " . gettype($data)); + // The error related to the "Esc" key has been fixed + public function processData(&$data): void + { + if ($data === null) { + $data = null; + return; + } + + if (!is_int($data)) { + throw new FormValidationException("Expected an integer response, got " . gettype($data)); + } + + if ($data === 0) { + $data = true; + } elseif ($data === 1) { + $data = false; + } else { + throw new FormValidationException("Button $data does not exist"); } } From 62573e6017c17e8dac2816e29d4931d7f5fe6b5e Mon Sep 17 00:00:00 2001 From: Ahmet <71610210+ayrzDev@users.noreply.github.com> Date: Sun, 5 Nov 2023 13:40:45 +0300 Subject: [PATCH 2/2] Update ModalForm.php --- src/jojoe77777/FormAPI/ModalForm.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/jojoe77777/FormAPI/ModalForm.php b/src/jojoe77777/FormAPI/ModalForm.php index 9ee0fa4..b008bee 100755 --- a/src/jojoe77777/FormAPI/ModalForm.php +++ b/src/jojoe77777/FormAPI/ModalForm.php @@ -24,6 +24,7 @@ public function __construct(?callable $callable) { } // The error related to the "Esc" key has been fixed + public function processData(&$data): void { if ($data === null) { @@ -31,17 +32,9 @@ public function processData(&$data): void return; } - if (!is_int($data)) { + if (!is_bool($data)) { throw new FormValidationException("Expected an integer response, got " . gettype($data)); } - - if ($data === 0) { - $data = true; - } elseif ($data === 1) { - $data = false; - } else { - throw new FormValidationException("Button $data does not exist"); - } } /**