Skip to content

Commit

Permalink
Rename SimpleForm::addButton() into addElement()
Browse files Browse the repository at this point in the history
  • Loading branch information
bbo51dog committed Apr 28, 2021
1 parent 5d2d2f8 commit 551cce4
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/bbo51dog/bboform/form/SimpleForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@

namespace bbo51dog\bboform\form;

use bbo51dog\bboform\element\Button;
use bbo51dog\bboform\element\SimpleFormElement;
use pocketmine\Player;

class SimpleForm extends FormBase {

/** @var string */
private $content = "";

/** @var Button[] */
private $buttons = [];
/** @var SimpleFormElement[] */
private $elements = [];

public function addButton(Button $element): self {
$this->buttons[] = $element;
/**
* @param SimpleFormElement $element
* @return $this
*/
public function addElement(SimpleFormElement $element): self {
$this->elements[] = $element;
return $this;
}

Expand All @@ -26,7 +30,7 @@ final public function handleResponse(Player $player, $data): void {
if ($data === null) {
return;
}
$this->buttons[$data]->handleSubmit($player);
$this->elements[$data]->handleSubmit($player);
$this->handleSubmit($player);
}

Expand All @@ -36,7 +40,7 @@ public function serializeContent() {

public function jsonSerialize(): array {
$data = parent::jsonSerialize();
foreach ($this->buttons as $element) {
foreach ($this->elements as $element) {
$data["buttons"][] = $element->jsonSerialize();
}
return $data;
Expand Down

0 comments on commit 551cce4

Please sign in to comment.