Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/jojoe77777/FormAPI/ModalForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@ 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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pointless

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It prevents you from getting a nasty error in the console. I don't understand what makes sense. Can you give a more detailed answer?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this branch is entered, $data is already null, so this assignment is doing nothing useful.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is overlooked in this plugin is that you get an error when you press the escape key. When the data is empty, either yes or no must be selected, so I added something like this to prevent an error if the data is empty.

return;
}

if (!is_bool($data)) {
throw new FormValidationException("Expected an integer response, got " . gettype($data));
}
}

Expand Down