diff --git a/src/Vecnavium/FormsUI/SimpleForm.php b/src/Vecnavium/FormsUI/SimpleForm.php index 092022d..5d08596 100644 --- a/src/Vecnavium/FormsUI/SimpleForm.php +++ b/src/Vecnavium/FormsUI/SimpleForm.php @@ -4,21 +4,29 @@ namespace Vecnavium\FormsUI; -class ModalForm extends Form { +class SimpleForm extends Form { + + const IMAGE_TYPE_PATH = 0; + const IMAGE_TYPE_URL = 1; /** @var string */ private $content = ""; + private $labelMap = []; + /** * @param callable|null $callable */ public function __construct(?callable $callable) { parent::__construct($callable); - $this->data["type"] = "modal"; + $this->data["type"] = "form"; $this->data["title"] = ""; $this->data["content"] = $this->content; - $this->data["button1"] = ""; - $this->data["button2"] = ""; + $this->data["buttons"] = []; + } + + public function processData(&$data) : void { + $data = $this->labelMap[$data] ?? null; } /** @@ -51,29 +59,18 @@ public function setContent(string $content) : void { /** * @param string $text + * @param int $imageType + * @param string $imagePath + * @param string $label */ - public function setButton1(string $text) : void { - $this->data["button1"] = $text; - } - - /** - * @return string - */ - public function getButton1() : string { - return $this->data["button1"]; - } - - /** - * @param string $text - */ - public function setButton2(string $text) : void { - $this->data["button2"] = $text; + public function addButton(string $text, int $imageType = -1, string $imagePath = "", ?string $label = null) : void { + $content = ["text" => $text]; + if($imageType !== -1) { + $content["image"]["type"] = $imageType === 0 ? "path" : "url"; + $content["image"]["data"] = $imagePath; + } + $this->data["buttons"][] = $content; + $this->labelMap[] = $label ?? count($this->labelMap); } - /** - * @return string - */ - public function getButton2() : string { - return $this->data["button2"]; - } } \ No newline at end of file