diff --git a/README.md b/README.md
index 9054fe1..0026370 100644
--- a/README.md
+++ b/README.md
@@ -19,3 +19,39 @@ projects:
- src: jojoe77777/FormAPI/libFormAPI
version: ^2.1.1
```
+
+## Add Features
+### HEADER
+
+
+For Developers:
+```php
+$form->addHeader(string $text);
+```
+
+### TOOLTIP
+
+
+For Developers:
+```php
+$form->addToggle("input", "", "", "this is tooltip");
+$form->addDropDown("select", ["1", "2", "3"], 0, "this is tooltip dropdown");
+.....
+```
+
+### DIVIDER
+
+
+For Developers:
+```php
+$form->addDivider();
+```
+
+### SET CUSTOM SUBMIT BUTTON
+
+
+For Developers:
+```php
+$form->setSubmitButton(string $text);
+```
+[
diff --git a/src/jojoe77777/FormAPI/CustomForm.php b/src/jojoe77777/FormAPI/CustomForm.php
index 8ae6171..a24a255 100755
--- a/src/jojoe77777/FormAPI/CustomForm.php
+++ b/src/jojoe77777/FormAPI/CustomForm.php
@@ -75,14 +75,20 @@ public function addLabel(string $text, ?string $label = null) : self {
/**
* @param string $text
* @param bool|null $default
+ * @parm string|null $tooltip
* @param string|null $label
* @return $this
*/
- public function addToggle(string $text, bool $default = null, ?string $label = null) : self {
+ public function addToggle(string $text, bool $default = null, string $tooltip = null, ?string $label = null) : self {
$content = ["type" => "toggle", "text" => $text];
if($default !== null) {
$content["default"] = $default;
}
+
+ if($tooltip !== null){
+ $content["tooltip"] = $tooltip;
+ }
+
$this->addContent($content);
$this->labelMap[] = $label ?? count($this->labelMap);
$this->validationMethods[] = static fn($v) => is_bool($v);
@@ -95,10 +101,11 @@ public function addToggle(string $text, bool $default = null, ?string $label = n
* @param int $max
* @param int $step
* @param int $default
+ * @param string|null $tooltip
* @param string|null $label
* @return $this
*/
- public function addSlider(string $text, int $min, int $max, int $step = -1, int $default = -1, ?string $label = null) : self {
+ public function addSlider(string $text, int $min, int $max, int $step = -1, int $default = -1, string $tooltip = null, ?string $label = null) : self {
$content = ["type" => "slider", "text" => $text, "min" => $min, "max" => $max];
if($step !== -1) {
$content["step"] = $step;
@@ -106,6 +113,9 @@ public function addSlider(string $text, int $min, int $max, int $step = -1, int
if($default !== -1) {
$content["default"] = $default;
}
+ if($tooltip !== null){
+ $content["tooltip"] = $tooltip;
+ }
$this->addContent($content);
$this->labelMap[] = $label ?? count($this->labelMap);
$this->validationMethods[] = static fn($v) => (is_float($v) || is_int($v)) && $v >= $min && $v <= $max;
@@ -116,14 +126,18 @@ public function addSlider(string $text, int $min, int $max, int $step = -1, int
* @param string $text
* @param array $steps
* @param int $defaultIndex
+ * @param string|null $tooltip
* @param string|null $label
* @return $this
*/
- public function addStepSlider(string $text, array $steps, int $defaultIndex = -1, ?string $label = null) : self {
+ public function addStepSlider(string $text, array $steps, int $defaultIndex = -1, string $tooltip = null, ?string $label = null) : self {
$content = ["type" => "step_slider", "text" => $text, "steps" => $steps];
if($defaultIndex !== -1) {
$content["default"] = $defaultIndex;
}
+ if($tooltip !== null){
+ $content["tooltip"] = $tooltip;
+ }
$this->addContent($content);
$this->labelMap[] = $label ?? count($this->labelMap);
$this->validationMethods[] = static fn($v) => is_int($v) && isset($steps[$v]);
@@ -134,11 +148,12 @@ public function addStepSlider(string $text, array $steps, int $defaultIndex = -1
* @param string $text
* @param array $options
* @param int|null $default
+ * @param string|null $tooltip
* @param string|null $label
* @return $this
*/
- public function addDropdown(string $text, array $options, int $default = null, ?string $label = null) : self {
- $this->addContent(["type" => "dropdown", "text" => $text, "options" => $options, "default" => $default]);
+ public function addDropdown(string $text, array $options, int $default = null, string $tooltip = null, ?string $label = null) : self {
+ $this->addContent(["type" => "dropdown", "text" => $text, "options" => $options, "default" => $default, "tooltip" => $tooltip]);
$this->labelMap[] = $label ?? count($this->labelMap);
$this->validationMethods[] = static fn($v) => is_int($v) && isset($options[$v]);
return $this;
@@ -148,15 +163,37 @@ public function addDropdown(string $text, array $options, int $default = null, ?
* @param string $text
* @param string $placeholder
* @param string|null $default
+ * @param string|null $tooltip
* @param string|null $label
* @return $this
*/
- public function addInput(string $text, string $placeholder = "", string $default = null, ?string $label = null) : self {
- $this->addContent(["type" => "input", "text" => $text, "placeholder" => $placeholder, "default" => $default]);
+ public function addInput(string $text, string $placeholder = "", string $default = null, string $tooltip = null, ?string $label = null) : self {
+ $this->addContent(["type" => "input", "text" => $text, "placeholder" => $placeholder, "default" => $default, "tooltip" => $tooltip]);
$this->labelMap[] = $label ?? count($this->labelMap);
$this->validationMethods[] = static fn($v) => is_string($v);
return $this;
}
+
+ /**
+ * @param string $text
+ * @return $this
+ */
+ public function addHeader(string $text, ?string $label = null) : self{
+ $this->addContent(["type" => "header", "text" => $text]);
+ $this->labelMap[] = $label ?? count($this->labelMap);
+ $this->validationMethods[] = static fn($v) => $v === null;
+ return $this;
+ }
+
+ /**
+ * @return $this
+ */
+ public function addDivider(?string $label = null) : self{
+ $this->addContent(["type" => "divider", "text" => ""]);
+ $this->labelMap[] = $label ?? count($this->labelMap);
+ $this->validationMethods[] = static fn($v) => $v === null;
+ return $this;
+ }
/**
* @param array $content
@@ -166,5 +203,4 @@ private function addContent(array $content) : self {
$this->data["content"][] = $content;
return $this;
}
-
}
diff --git a/src/jojoe77777/FormAPI/Form.php b/src/jojoe77777/FormAPI/Form.php
index 12e248a..ccd6ee2 100755
--- a/src/jojoe77777/FormAPI/Form.php
+++ b/src/jojoe77777/FormAPI/Form.php
@@ -32,6 +32,13 @@ public function sendToPlayer(Player $player) : void {
$player->sendForm($this);
}
+ /**
+ * @param string $text
+ */
+ public function setSubmitButton(string $text) : void{
+ $this->data["submit"] = $text;
+ }
+
public function getCallable() : ?callable {
return $this->callable;
}