diff --git a/docs/00-intro.md b/docs/00-intro.md
index 047b0ec..3622f37 100644
--- a/docs/00-intro.md
+++ b/docs/00-intro.md
@@ -10,7 +10,7 @@ Mostly everything you need to build and process form is available in this packag
The first part is most input callable as a widget :
```
-{% ui.text "fullname", "John Doe" %}
+{% ui:text "fullname", "John Doe" %}
```
Current input support is :
@@ -41,30 +41,30 @@ Current input support is :
**[PICEA]** So, using this code:
```html
-{% ui.form.post "user.save", current_url() %}
+{% ui:form.post "user.save", current_url() %}
Full name
- {% ui.text "fullname", $user->fullname, [ 'required' => 'required' ] %}
+ {% ui:text "fullname", $user->fullname, [ 'required' => 'required' ] %}
Email address
- {% ui.text "email", $user->email %}
+ {% ui:text "email", $user->email %}
Have a job
- {% ui.radio "job", 'yes', [], [ 'value' => $entity->job ] %} Yes
- {% ui.radio "job", 'no', [], [ 'value' => $entity->job ] %} No
+ {% ui:radio "job", 'yes', [], [ 'value' => $entity->job ] %} Yes
+ {% ui:radio "job", 'no', [], [ 'value' => $entity->job ] %} No
Role
- {% ui.select "role", [ 'user' => "User", 'moderator' => "Moderator", 'admin' => "Admin" ], $user->role, [ 'required' => 'required' ] %}
+ {% ui:select "role", [ 'user' => "User", 'moderator' => "Moderator", 'admin' => "Admin" ], $user->role, [ 'required' => 'required' ] %}
Save
-{% ui.endform %}
+{% ui:endform %}
```
**[HTML]** Would render as such:
diff --git a/docs/10-ui-checkbox.md b/docs/10-ui-checkbox.md
index 11eb9a3..746eeaa 100644
--- a/docs/10-ui-checkbox.md
+++ b/docs/10-ui-checkbox.md
@@ -1,6 +1,6 @@
-# `ui.checkbox` (string $name, mixed $value = null, array $attributes = [], array $options = [])
+# `ui:checkbox` (string $name, mixed $value = null, array $attributes = [], array $options = [])
-Built on top of `ui.radio` component, which itself extends `ui.input`.
+Built on top of `ui:radio` component, which itself extends `ui:input`.
The following attributes are assigned by this extension :
diff --git a/docs/10-ui-color.md b/docs/10-ui-color.md
index ee647ea..74e6157 100644
--- a/docs/10-ui-color.md
+++ b/docs/10-ui-color.md
@@ -1,6 +1,6 @@
-# `ui.color` (string $name, mixed $value = null, array $attributes = [], array $options = [])
+# `ui:color` (string $name, mixed $value = null, array $attributes = [], array $options = [])
-Built on top of `ui.input`.
+Built on top of `ui:input`.
The following attributes are assigned by this extension :
diff --git a/docs/10-ui-date.md b/docs/10-ui-date.md
index 7855512..5f3dded 100644
--- a/docs/10-ui-date.md
+++ b/docs/10-ui-date.md
@@ -1,6 +1,6 @@
-# `ui.date` (string $name, mixed $value = null, array $attributes = [], array $options = [])
+# `ui:date` (string $name, mixed $value = null, array $attributes = [], array $options = [])
-Built on top of `ui.input`.
+Built on top of `ui:input`.
The following attributes are assigned by this extension :
diff --git a/docs/10-ui-datetime.md b/docs/10-ui-datetime.md
index 47bafd2..a400ecb 100644
--- a/docs/10-ui-datetime.md
+++ b/docs/10-ui-datetime.md
@@ -1,6 +1,6 @@
-# `ui.datetime` (string $name, mixed $value = null, array $attributes = [], array $options = [])
+# `ui:datetime` (string $name, mixed $value = null, array $attributes = [], array $options = [])
-Built on top of `ui.input`.
+Built on top of `ui:input`.
The following attributes are assigned by this extension :
diff --git a/docs/10-ui-email.md b/docs/10-ui-email.md
index 9779149..0428645 100644
--- a/docs/10-ui-email.md
+++ b/docs/10-ui-email.md
@@ -1,6 +1,6 @@
-# `ui.email` (string $name, mixed $value = null, array $attributes = [], array $options = [])
+# `ui:email` (string $name, mixed $value = null, array $attributes = [], array $options = [])
-Built on top of `ui.input`.
+Built on top of `ui:input`.
The following attributes are assigned by this extension :
diff --git a/docs/10-ui-file.md b/docs/10-ui-file.md
index 4b6d120..979dcfe 100644
--- a/docs/10-ui-file.md
+++ b/docs/10-ui-file.md
@@ -1,6 +1,6 @@
-# `ui.file` (string $name, mixed $value = null, array $attributes = [], array $options = [])
+# `ui:file` (string $name, mixed $value = null, array $attributes = [], array $options = [])
-Built on top of `ui.input`.
+Built on top of `ui:input`.
The following attributes are assigned by this extension :
diff --git a/docs/10-ui-form.md b/docs/10-ui-form.md
index 6bbacb7..b5a8173 100644
--- a/docs/10-ui-form.md
+++ b/docs/10-ui-form.md
@@ -1,6 +1,6 @@
-# `ui.form` / `ui.form.get` / `ui.form.post` (string $method = "get", string $name = "", string $action = "", array $attributes = [])
+# `ui:form` / `ui:form.get` / `ui:form.post` (string $method = "get", string $name = "", string $action = "", array $attributes = [])
-A version exists also for unsupported methods (as of HTML5) on forms `ui.form.put` / `ui.form.patch` / `ui.form.delete`, which
+A version exists also for unsupported methods (as of HTML5) on forms `ui:form.put` / `ui:form.patch` / `ui:form.delete`, which
could find a use within a Javascript environment.
The following attributes are assigned by this extension :
diff --git a/docs/10-ui-hidden.md b/docs/10-ui-hidden.md
index 69de9cf..b82bdd7 100644
--- a/docs/10-ui-hidden.md
+++ b/docs/10-ui-hidden.md
@@ -1,6 +1,6 @@
-# `ui.hidden` (string $name, mixed $value = null, array $attributes = [], array $options = [])
+# `ui:hidden` (string $name, mixed $value = null, array $attributes = [], array $options = [])
-Built on top of `ui.input`.
+Built on top of `ui:input`.
The following attributes are assigned by this extension :
diff --git a/docs/10-ui-image.md b/docs/10-ui-image.md
index 1027a74..8821026 100644
--- a/docs/10-ui-image.md
+++ b/docs/10-ui-image.md
@@ -1,6 +1,6 @@
-# `ui.image` (string $source, array $attributes = [], array $options = [])
+# `ui:image` (string $source, array $attributes = [], array $options = [])
-Built on top of `ui.input`.
+Built on top of `ui:input`.
The following attributes are assigned by this extension :
diff --git a/docs/10-ui-input.md b/docs/10-ui-input.md
index ee8790c..a1aa205 100644
--- a/docs/10-ui-input.md
+++ b/docs/10-ui-input.md
@@ -1,4 +1,4 @@
-# `ui.input` (string $name, mixed $value = null, array $attributes = [], array $options = [])
+# `ui:input` (string $name, mixed $value = null, array $attributes = [], array $options = [])
This is small
diff --git a/docs/10-ui-numeric.md b/docs/10-ui-numeric.md
index b7c8571..f696451 100644
--- a/docs/10-ui-numeric.md
+++ b/docs/10-ui-numeric.md
@@ -1,6 +1,6 @@
-# `ui.numeric` (string $name, mixed $value = null, array $attributes = [], array $options = [])
+# `ui:numeric` (string $name, mixed $value = null, array $attributes = [], array $options = [])
-Built on top of `ui.input`.
+Built on top of `ui:input`.
The following attributes are assigned by this extension :
diff --git a/docs/10-ui-password.md b/docs/10-ui-password.md
index 0d9b359..cfe4738 100644
--- a/docs/10-ui-password.md
+++ b/docs/10-ui-password.md
@@ -1,6 +1,6 @@
-# `ui.password` (string $name, mixed $value = null, array $attributes = [], array $options = [])
+# `ui:password` (string $name, mixed $value = null, array $attributes = [], array $options = [])
-Built on top of `ui.input`.
+Built on top of `ui:input`.
The following attributes are assigned by this extension :
diff --git a/docs/10-ui-radio.md b/docs/10-ui-radio.md
index 46d8a6d..2e8cf03 100644
--- a/docs/10-ui-radio.md
+++ b/docs/10-ui-radio.md
@@ -1,6 +1,6 @@
-# `ui.radio` (string $name, mixed $value = null, array $attributes = [], array $options = [])
+# `ui:radio` (string $name, mixed $value = null, array $attributes = [], array $options = [])
-Built on top of `ui.input`.
+Built on top of `ui:input`.
The following attributes are assigned by this extension :
diff --git a/docs/10-ui-range.md b/docs/10-ui-range.md
index 3f258f2..418bef0 100644
--- a/docs/10-ui-range.md
+++ b/docs/10-ui-range.md
@@ -1,6 +1,6 @@
-# `ui.range` (string $name, mixed $value = null, array $attributes = [], array $options = [])
+# `ui:range` (string $name, mixed $value = null, array $attributes = [], array $options = [])
-Built on top of `ui.input`.
+Built on top of `ui:input`.
The following attributes are assigned by this extension :
diff --git a/docs/10-ui-search.md b/docs/10-ui-search.md
index 035a021..4fb3c7a 100644
--- a/docs/10-ui-search.md
+++ b/docs/10-ui-search.md
@@ -1,6 +1,6 @@
-# `ui.search` (string $name, mixed $value = null, array $attributes = [], array $options = [])
+# `ui:search` (string $name, mixed $value = null, array $attributes = [], array $options = [])
-Built on top of `ui.input`.
+Built on top of `ui:input`.
The following attributes are assigned by this extension :
diff --git a/docs/10-ui-select.md b/docs/10-ui-select.md
index 071de73..f491062 100644
--- a/docs/10-ui-select.md
+++ b/docs/10-ui-select.md
@@ -1,6 +1,6 @@
-# `ui.select` (string $name, array $list, $value = null, array $attributes = [], bool $strictComparison = true)
+# `ui:select` (string $name, array $list, $value = null, array $attributes = [], bool $strictComparison = true)
-Built on top of `ui.input`.
+Built on top of `ui:input`.
The following attributes are assigned by this extension :
diff --git a/docs/10-ui-tel.md b/docs/10-ui-tel.md
index 2a9a413..c65591d 100644
--- a/docs/10-ui-tel.md
+++ b/docs/10-ui-tel.md
@@ -1,6 +1,6 @@
-# `ui.tel` (string $name, mixed $value = null, array $attributes = [], array $options = [])
+# `ui:tel` (string $name, mixed $value = null, array $attributes = [], array $options = [])
-Built on top of `ui.input`.
+Built on top of `ui:input`.
The following attributes are assigned by this extension :
diff --git a/docs/10-ui-text.md b/docs/10-ui-text.md
index 04e08a0..042f497 100644
--- a/docs/10-ui-text.md
+++ b/docs/10-ui-text.md
@@ -1,6 +1,6 @@
-# `ui.text` (string $name, mixed $value = null, array $attributes = [], array $options = [])
+# `ui:text` (string $name, mixed $value = null, array $attributes = [], array $options = [])
-Built on top of `ui.input`.
+Built on top of `ui:input`.
The following attributes are assigned by this extension :
diff --git a/docs/10-ui-textarea.md b/docs/10-ui-textarea.md
index 148e475..7d399b2 100644
--- a/docs/10-ui-textarea.md
+++ b/docs/10-ui-textarea.md
@@ -1,6 +1,6 @@
-# `ui.textarea` / `ui.textarea.raw` (string $name, mixed $value = null, array $attributes = [], array $options = [])
+# `ui:textarea` / `ui:textarea.raw` (string $name, mixed $value = null, array $attributes = [], array $options = [])
-Built on top of `ui.input`. This extension also comes with a raw modifier which skips the escaping.
+Built on top of `ui:input`. This extension also comes with a raw modifier which skips the escaping.
The following attributes are assigned by this extension :
diff --git a/docs/10-ui-time.md b/docs/10-ui-time.md
index fbdb592..049ad44 100644
--- a/docs/10-ui-time.md
+++ b/docs/10-ui-time.md
@@ -1,6 +1,6 @@
-# `ui.time` (string $name, mixed $value = null, array $attributes = [], array $options = [])
+# `ui:time` (string $name, mixed $value = null, array $attributes = [], array $options = [])
-Built on top of `ui.input`.
+Built on top of `ui:input`.
The following attributes are assigned by this extension :
diff --git a/docs/10-ui-url.md b/docs/10-ui-url.md
index 3957336..97ddab1 100644
--- a/docs/10-ui-url.md
+++ b/docs/10-ui-url.md
@@ -1,6 +1,6 @@
-# `ui.url` (string $name, mixed $value = null, array $attributes = [], array $options = [])
+# `ui:url` (string $name, mixed $value = null, array $attributes = [], array $options = [])
-Built on top of `ui.input`.
+Built on top of `ui:input`.
The following attributes are assigned by this extension :
diff --git a/docs/10-ui-week.md b/docs/10-ui-week.md
index 6e211ad..4cd1890 100644
--- a/docs/10-ui-week.md
+++ b/docs/10-ui-week.md
@@ -1,6 +1,6 @@
-# `ui.week` (string $name, mixed $value = null, array $attributes = [], array $options = [])
+# `ui:week` (string $name, mixed $value = null, array $attributes = [], array $options = [])
-Built on top of `ui.input`.
+Built on top of `ui:input`.
The following attributes are assigned by this extension :
diff --git a/docs/30-component-popup.md b/docs/30-component-popup.md
index 3284bfd..5d1e9d3 100644
--- a/docs/30-component-popup.md
+++ b/docs/30-component-popup.md
@@ -1,4 +1,4 @@
-# `ui.popup` (string $name, array $variables = [], array $options = [])
+# `ui:popup` (string $name, array $variables = [], array $options = [])
The following attributes are assigned by this extension :
diff --git a/src/Component/UiMessage.php b/src/Component/UiMessage.php
index 1c89bf7..bb23f60 100644
--- a/src/Component/UiMessage.php
+++ b/src/Component/UiMessage.php
@@ -9,7 +9,7 @@ use Picea\Extension\ExtensionTrait;
class UiMessage extends UiElement implements Extension {
use ExtensionTrait;
- public string $token = "ui.message";
+ public string $token = "ui:message";
public string $tag = "input";
diff --git a/src/Component/UiPopup.php b/src/Component/UiPopup.php
index 6fac143..bbb42ba 100644
--- a/src/Component/UiPopup.php
+++ b/src/Component/UiPopup.php
@@ -9,7 +9,7 @@ use Picea\Extension\ExtensionTrait;
class UiPopup extends UiElement implements Extension {
use ExtensionTrait;
- public string $token = "ui.popup";
+ public string $token = "ui:popup";
public string $tag = "div";
diff --git a/src/Form/Ui.php b/src/Form/Ui.php
new file mode 100644
index 0000000..df22c23
--- /dev/null
+++ b/src/Form/Ui.php
@@ -0,0 +1,129 @@
+tokenOptions($token);
+
+ switch(true) {
+ case in_array('checkbox', $opt):
+ $input = new UiCheckbox();
+ break;
+
+ case in_array('color', $opt):
+ $input = new UiColor();
+ break;
+
+ case in_array('date', $opt):
+ $input = new UiDate();
+ break;
+
+ case in_array('datetime', $opt):
+ $input = new UiDatetime();
+ break;
+
+ case in_array('email', $opt):
+ $input = new UiEmail();
+ break;
+
+ case in_array('file', $opt):
+ $input = new UiFile();
+ break;
+
+ case in_array('form', $opt):
+ case in_array('endform', $opt):
+ $input = new UiForm();
+ break;
+
+ case in_array('hidden', $opt):
+ $input = new UiHidden();
+ break;
+
+ case in_array('image', $opt):
+ $input = new UiImage();
+ break;
+
+ case in_array('input', $opt):
+ $input = new UiInput();
+ break;
+
+ case in_array('numeric', $opt):
+ $input = new UiNumeric();
+ break;
+
+ case in_array('password', $opt):
+ $input = new UiPassword();
+ break;
+
+ case in_array('radio', $opt):
+ $input = new UiRadio();
+ break;
+
+ case in_array('range', $opt):
+ $input = new UiRange();
+ break;
+
+ case in_array('search', $opt):
+ $input = new UiSearch();
+ break;
+
+ case in_array('select', $opt):
+ $input = new UiSelect();
+ break;
+
+ case in_array('tel', $opt):
+ $input = new UiTel();
+ break;
+
+ case in_array('text', $opt):
+ $input = new UiText();
+ break;
+
+ case in_array('textarea', $opt):
+ $input = new UiTextarea();
+ break;
+
+ case in_array('time', $opt):
+ $input = new UiText();
+ break;
+
+ case in_array('url', $opt):
+ $input = new UiUrl();
+ break;
+
+ case in_array('week', $opt):
+ $input = new UiWeek();
+ break;
+
+ case in_array('popup', $opt):
+ $input = new UiPopup();
+ break;
+
+ case in_array('message', $opt):
+ $input = new UiMessage();
+ break;
+ }
+
+ if (empty($input)) {
+ throw new \Exception("Missing token ? $token");
+ }
+
+ return $input->parse($context, $arguments, $token);
+ }
+}
diff --git a/src/Form/UiCheckbox.php b/src/Form/UiCheckbox.php
index 7a9fcd8..fe05868 100644
--- a/src/Form/UiCheckbox.php
+++ b/src/Form/UiCheckbox.php
@@ -4,7 +4,7 @@ namespace Picea\Ui\Form;
class UiCheckbox extends UiRadio {
- public string $token = "ui.checkbox";
+ public string $token = "ui:checkbox";
public array $attributes = [
'class' => "ui-checkbox",
diff --git a/src/Form/UiColor.php b/src/Form/UiColor.php
index 4b5fd84..3166452 100644
--- a/src/Form/UiColor.php
+++ b/src/Form/UiColor.php
@@ -4,7 +4,7 @@ namespace Picea\Ui\Form;
class UiColor extends UiInput {
- public string $token = "ui.color";
+ public string $token = "ui:color";
public array $attributes = [
'class' => "ui-color",
diff --git a/src/Form/UiDate.php b/src/Form/UiDate.php
index a2eeeb4..87896e2 100644
--- a/src/Form/UiDate.php
+++ b/src/Form/UiDate.php
@@ -4,7 +4,7 @@ namespace Picea\Ui\Form;
class UiDate extends UiInput {
- public string $token = "ui.date";
+ public string $token = "ui:date";
public array $attributes = [
'class' => "ui-date",
diff --git a/src/Form/UiDatetime.php b/src/Form/UiDatetime.php
index bf9aeeb..76adcc1 100644
--- a/src/Form/UiDatetime.php
+++ b/src/Form/UiDatetime.php
@@ -4,7 +4,7 @@ namespace Picea\Ui\Form;
class UiDatetime extends UiInput {
- public string $token = "ui.datetime";
+ public string $token = "ui:datetime";
public array $attributes = [
'class' => "ui-datetime",
diff --git a/src/Form/UiEmail.php b/src/Form/UiEmail.php
index 1e4b499..56043bf 100644
--- a/src/Form/UiEmail.php
+++ b/src/Form/UiEmail.php
@@ -4,7 +4,7 @@ namespace Picea\Ui\Form;
class UiEmail extends UiInput {
- public string $token = "ui.email";
+ public string $token = "ui:email";
public array $attributes = [
'class' => "ui-email",
diff --git a/src/Form/UiFile.php b/src/Form/UiFile.php
index 7b45f7c..94f913c 100644
--- a/src/Form/UiFile.php
+++ b/src/Form/UiFile.php
@@ -4,7 +4,7 @@ namespace Picea\Ui\Form;
class UiFile extends UiInput {
- public string $token = "ui.file";
+ public string $token = "ui:file";
public array $attributes = [
'class' => "ui-file",
diff --git a/src/Form/UiForm.php b/src/Form/UiForm.php
index 33ff100..337d5fb 100644
--- a/src/Form/UiForm.php
+++ b/src/Form/UiForm.php
@@ -11,7 +11,7 @@ class UiForm extends UiElement implements Extension {
public string $defaultMethod = "get";
- public array $token = [ "ui.form", "ui.endform", "ui.form.get", "ui.form.post", "ui.form.patch", "ui.form.delete", "ui.form.put" ];
+ public array $token = [ "ui:form", "ui:endform" /*, "ui:form.get", "ui:form.post", "ui:form.patch", "ui:form.delete", "ui:form.put"*/ ];
public string $tag = "form";
@@ -22,41 +22,45 @@ class UiForm extends UiElement implements Extension {
public function parse(\Picea\Compiler\Context &$context, ?string $arguments, string $token) : string
{
switch($token) {
- case 'ui.endform':
+ case 'ui:endform':
return "";
+ }
- case "ui.form.get":
- $method = "get";
- break;
+ $opt = $context->tokenOptions($token, true);
- case "ui.form.patch":
- $method = "patch";
- break;
-
- case "ui.form.delete":
- $method = "delete";
- break;
-
- case "ui.form.put":
- $method = "put";
- break;
-
- case "ui.form.post":
- $method = "post";
- break;
+ if (in_array('get', $opt)) {
+ $method = "get";
+ }
+ elseif (in_array('post', $opt)) {
+ $method = "post";
+ }
+ elseif (in_array('put', $opt)) {
+ $method = "put";
+ }
+ elseif (in_array('delete', $opt)) {
+ $method = "delete";
+ }
+ elseif (in_array('patch', $opt)) {
+ $method = "patch";
}
$method ??= $this->defaultMethod;
-
- return "buildHtml('$method', $arguments) ?>";
+
+ return "parseOptions($opt)->buildHtml('$method', $arguments) ?>";
}
-
+
+ public function parseOptions($options) : self
+ {
+ $this->options = $options;
+
+ return $this;
+ }
+
public function buildHtml(string $method = "get", string $name = "", string $action = "", array $attributes = []) : string
{
$method = strtolower($method);
$this->option('tag-type', 'single');
-
if ($attributes['class'] ?? false) {
$attributes['class'] .= " {$this->attributes['class']}";
@@ -67,7 +71,7 @@ class UiForm extends UiElement implements Extension {
if ( $method !== "get" ) {
$token = md5( $name . microtime());
- $key = "picea-ui.form:{$name}";
+ $key = "picea-ui:form:{$name}";
if (count($_SESSION[$key] ?? []) > 100) {
array_shift($_SESSION[$key]);
diff --git a/src/Form/UiHidden.php b/src/Form/UiHidden.php
index 9cb6c18..0361775 100644
--- a/src/Form/UiHidden.php
+++ b/src/Form/UiHidden.php
@@ -4,7 +4,7 @@ namespace Picea\Ui\Form;
class UiHidden extends UiInput {
- public string $token = "ui.hidden";
+ public string $token = "ui:hidden";
public array $attributes = [
'class' => "ui-hidden",
diff --git a/src/Form/UiImage.php b/src/Form/UiImage.php
index c51b0bf..e72ea3c 100644
--- a/src/Form/UiImage.php
+++ b/src/Form/UiImage.php
@@ -9,7 +9,7 @@ use Picea\Extension\ExtensionTrait;
class UiImage extends UiElement implements Extension {
use ExtensionTrait;
- public string $token = "ui.img";
+ public array $tokens = [ "ui:img", "ui:image" ];
public string $tag = "img";
diff --git a/src/Form/UiInput.php b/src/Form/UiInput.php
index f185793..6646434 100644
--- a/src/Form/UiInput.php
+++ b/src/Form/UiInput.php
@@ -9,7 +9,7 @@ use Picea\Extension\ExtensionTrait;
class UiInput extends UiElement implements Extension {
use ExtensionTrait;
- public string $token = "ui.input";
+ public string $token = "ui:input";
public string $tag = "input";
diff --git a/src/Form/UiNumeric.php b/src/Form/UiNumeric.php
index c0ab774..2f10ac6 100644
--- a/src/Form/UiNumeric.php
+++ b/src/Form/UiNumeric.php
@@ -4,7 +4,7 @@ namespace Picea\Ui\Form;
class UiNumeric extends UiInput {
- public string $token = "ui.numeric";
+ public string $token = "ui:numeric";
public array $attributes = [
'class' => "ui-numeric",
diff --git a/src/Form/UiPassword.php b/src/Form/UiPassword.php
index 5c15980..80b0339 100644
--- a/src/Form/UiPassword.php
+++ b/src/Form/UiPassword.php
@@ -4,7 +4,7 @@ namespace Picea\Ui\Form;
class UiPassword extends UiInput {
- public string $token = "ui.password";
+ public string $token = "ui:password";
public array $attributes = [
'class' => "ui-password",
diff --git a/src/Form/UiRadio.php b/src/Form/UiRadio.php
index d335d22..7ff99e8 100644
--- a/src/Form/UiRadio.php
+++ b/src/Form/UiRadio.php
@@ -4,7 +4,7 @@ namespace Picea\Ui\Form;
class UiRadio extends UiInput {
- public string $token = "ui.radio";
+ public string $token = "ui:radio";
public array $attributes = [
'class' => "ui-radio",
diff --git a/src/Form/UiRange.php b/src/Form/UiRange.php
index ae961ac..3734922 100644
--- a/src/Form/UiRange.php
+++ b/src/Form/UiRange.php
@@ -4,7 +4,7 @@ namespace Picea\Ui\Form;
class UiRange extends UiInput {
- public string $token = "ui.range";
+ public string $token = "ui:range";
public array $attributes = [
'class' => "ui-range",
diff --git a/src/Form/UiSearch.php b/src/Form/UiSearch.php
index e12717f..6f4d1b3 100644
--- a/src/Form/UiSearch.php
+++ b/src/Form/UiSearch.php
@@ -4,7 +4,7 @@ namespace Picea\Ui\Form;
class UiSearch extends UiInput {
- public string $token = "ui.search";
+ public string $token = "ui:search";
public array $attributes = [
'class' => "ui-search",
diff --git a/src/Form/UiSelect.php b/src/Form/UiSelect.php
index 7ac20f1..70fd69b 100644
--- a/src/Form/UiSelect.php
+++ b/src/Form/UiSelect.php
@@ -9,7 +9,7 @@ use Picea\Extension\ExtensionTrait;
class UiSelect extends UiElement implements Extension {
use ExtensionTrait;
- public string $token = "ui.select";
+ public string $token = "ui:select";
public string $tag = "select";
diff --git a/src/Form/UiTel.php b/src/Form/UiTel.php
index 754192a..8d56bec 100644
--- a/src/Form/UiTel.php
+++ b/src/Form/UiTel.php
@@ -4,7 +4,7 @@ namespace Picea\Ui\Form;
class UiTel extends UiInput {
- public string $token = "ui.tel";
+ public string $token = "ui:tel";
public array $attributes = [
'class' => "ui-tel",
diff --git a/src/Form/UiText.php b/src/Form/UiText.php
index 928b376..7e36f25 100644
--- a/src/Form/UiText.php
+++ b/src/Form/UiText.php
@@ -4,7 +4,7 @@ namespace Picea\Ui\Form;
class UiText extends UiInput {
- public string $token = "ui.text";
+ public string $token = "ui:text";
public array $attributes = [
'class' => "ui-text",
diff --git a/src/Form/UiTextarea.php b/src/Form/UiTextarea.php
index 59d865f..34d231b 100644
--- a/src/Form/UiTextarea.php
+++ b/src/Form/UiTextarea.php
@@ -4,7 +4,7 @@ namespace Picea\Ui\Form;
class UiTextarea extends UiInput {
- public array $tokens = [ "ui.textarea", "ui.textarea.raw" ];
+ public array $tokens = [ "ui:textarea" ];
public string $tag = "textarea";
@@ -18,11 +18,7 @@ class UiTextarea extends UiInput {
public function parse(\Picea\Compiler\Context &$context, ?string $arguments, string $token) : string
{
- if ($token === 'ui.textarea.raw') {
- $this->echoRaw = true;
- }
-
- $raw = $this->echoRaw ? 'true' : 'false';
+ $raw = in_array('raw', $context->tokenOptions($token, true)) ? 'true' : 'false';
return "echoRaw($raw)->buildHtml($arguments) ?>";
}
diff --git a/src/Form/UiTime.php b/src/Form/UiTime.php
index 6b0e53d..ce9af53 100644
--- a/src/Form/UiTime.php
+++ b/src/Form/UiTime.php
@@ -4,7 +4,7 @@ namespace Picea\Ui\Form;
class UiTime extends UiInput {
- public string $token = "ui.time";
+ public string $token = "ui:time";
public array $attributes = [
'class' => "ui-time",
diff --git a/src/Form/UiUrl.php b/src/Form/UiUrl.php
index f5ac8c6..9f67d65 100644
--- a/src/Form/UiUrl.php
+++ b/src/Form/UiUrl.php
@@ -4,7 +4,7 @@ namespace Picea\Ui\Form;
class UiUrl extends UiInput {
- public string $token = "ui.url";
+ public string $token = "ui:url";
public array $attributes = [
'class' => "ui-url",
diff --git a/src/Form/UiWeek.php b/src/Form/UiWeek.php
index fd3d621..1670c57 100644
--- a/src/Form/UiWeek.php
+++ b/src/Form/UiWeek.php
@@ -4,7 +4,7 @@ namespace Picea\Ui\Form;
class UiWeek extends UiInput {
- public string $token = "ui.week";
+ public string $token = "ui:week";
public array $attributes = [
'class' => "ui-week",
diff --git a/src/Ui.php b/src/Ui.php
index 0712b71..384829f 100644
--- a/src/Ui.php
+++ b/src/Ui.php
@@ -8,6 +8,9 @@ class Ui {
public function registerFormExtension(Compiler $compiler) : self
{
+ # BW compatibility with v1.x syntax
+ $compiler->registerExtension(new Form\Ui());
+
$compiler->registerExtension(new Form\UiForm());
$compiler->registerExtension(new Form\UiInput());
$compiler->registerExtension(new Form\UiCheckbox());