Skip to content

Commit

Permalink
What the..
Browse files Browse the repository at this point in the history
  • Loading branch information
Vecnavium committed Dec 17, 2021
1 parent 6314042 commit 53d3598
Showing 1 changed file with 23 additions and 26 deletions.
49 changes: 23 additions & 26 deletions src/Vecnavium/FormsUI/SimpleForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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"];
}
}

0 comments on commit 53d3598

Please sign in to comment.