Skip to content

Commit

Permalink
Fixed incorrect button/element keys
Browse files Browse the repository at this point in the history
  • Loading branch information
J1b1x committed Dec 30, 2023
1 parent cd65b34 commit 9bba543
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/Jibix/Forms/form/type/CustomForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,18 @@ public static function fromData(array $elements, array $data): array{
);
}

/**
* CustomForm constructor.
* @param string $title
* @param Element[] $elements
* @param Closure|null $onSubmit
* @param Closure|null $onClose
*/
/** @var Element[] */
protected array $elements = [];

public function __construct(
string $title,
protected array $elements,
array $elements = [],
protected ?Closure $onSubmit = null,
protected ?Closure $onClose = null,
){
if ($onSubmit !== null) Utils::validateCallableSignature(function (Player $player, CustomFormResponse $response){}, $onSubmit);
if ($onClose !== null) Utils::validateCallableSignature(function (Player $player){}, $onClose);
$this->elements = array_values($elements);
parent::__construct($title);
}

Expand Down
6 changes: 5 additions & 1 deletion src/Jibix/Forms/form/type/MenuForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@
*/
class MenuForm extends Form{

/** @var Button[] */
protected array $buttons = [];

public function __construct(
string $title,
protected string $content = "",
protected array $buttons = [],
array $buttons = [],
protected ?Closure $onSubmit = null,
protected ?Closure $onClose = null,
){
if ($onSubmit !== null) Utils::validateCallableSignature(function (Player $player, Button $selected){}, $onSubmit);
if ($onClose !== null) Utils::validateCallableSignature(function (Player $player){}, $onClose);
$this->buttons = array_values($buttons);
parent::__construct($title);
}

Expand Down

0 comments on commit 9bba543

Please sign in to comment.