- First task of v2 done
This commit is contained in:
		
							parent
							
								
									30ddd4c98b
								
							
						
					
					
						commit
						5397ed4fae
					
				| @ -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() %} | ||||
|     <div class="field fullname"> | ||||
|         <label>Full name</label> | ||||
|         {% ui.text "fullname", $user->fullname, [ 'required' => 'required' ] %} | ||||
|         {% ui:text "fullname", $user->fullname, [ 'required' => 'required' ] %} | ||||
|     </div> | ||||
|      | ||||
|     <div class="field email"> | ||||
|         <label>Email address</label> | ||||
|         {% ui.text "email", $user->email %} | ||||
|         {% ui:text "email", $user->email %} | ||||
|     </div> | ||||
| 
 | ||||
|     <div class="field job"> | ||||
|         <label>Have a job</label> | ||||
|         <label>{% ui.radio "job", 'yes', [], [ 'value' => $entity->job ] %} Yes</label> | ||||
|         <label>{% ui.radio "job", 'no', [], [ 'value' => $entity->job ] %} No</label> | ||||
|         <label>{% ui:radio "job", 'yes', [], [ 'value' => $entity->job ] %} Yes</label> | ||||
|         <label>{% ui:radio "job", 'no', [], [ 'value' => $entity->job ] %} No</label> | ||||
|     </div> | ||||
|      | ||||
|     <div class="field role"> | ||||
|         <label>Role</label> | ||||
|         {% 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' ] %} | ||||
|     </div> | ||||
| 
 | ||||
|     <button type="submit">Save</button> | ||||
| {% ui.endform %} | ||||
| {% ui:endform %} | ||||
| ``` | ||||
| 
 | ||||
| **[HTML]** Would render as such: | ||||
|  | ||||
| @ -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 : | ||||
| 
 | ||||
|  | ||||
| @ -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 : | ||||
| 
 | ||||
|  | ||||
| @ -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 : | ||||
| 
 | ||||
|  | ||||
| @ -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 : | ||||
| 
 | ||||
|  | ||||
| @ -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 : | ||||
| 
 | ||||
|  | ||||
| @ -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 : | ||||
| 
 | ||||
|  | ||||
| @ -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 : | ||||
|  | ||||
| @ -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 : | ||||
| 
 | ||||
|  | ||||
| @ -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 : | ||||
| 
 | ||||
|  | ||||
| @ -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 | ||||
| 
 | ||||
|  | ||||
| @ -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 : | ||||
| 
 | ||||
|  | ||||
| @ -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 : | ||||
| 
 | ||||
|  | ||||
| @ -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 : | ||||
| 
 | ||||
|  | ||||
| @ -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 : | ||||
| 
 | ||||
|  | ||||
| @ -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 : | ||||
| 
 | ||||
|  | ||||
| @ -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 : | ||||
| 
 | ||||
|  | ||||
| @ -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 : | ||||
| 
 | ||||
|  | ||||
| @ -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 : | ||||
| 
 | ||||
|  | ||||
| @ -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 : | ||||
| 
 | ||||
|  | ||||
| @ -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 : | ||||
| 
 | ||||
|  | ||||
| @ -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 : | ||||
| 
 | ||||
|  | ||||
| @ -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 : | ||||
| 
 | ||||
|  | ||||
| @ -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 : | ||||
| 
 | ||||
|  | ||||
| @ -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"; | ||||
| 
 | ||||
|  | ||||
| @ -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"; | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										129
									
								
								src/Form/Ui.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										129
									
								
								src/Form/Ui.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,129 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Picea\Ui\Form; | ||||
| 
 | ||||
| use Picea\Extension\Extension; | ||||
| use Picea\Extension\ExtensionTrait; | ||||
| use Picea\Ui\Common\UiElement; | ||||
| use Picea\Ui\Component\UiMessage; | ||||
| use Picea\Ui\Component\UiPopup; | ||||
| 
 | ||||
| class Ui extends UiElement implements Extension { | ||||
|     use ExtensionTrait; | ||||
| 
 | ||||
|     public string $token = "ui"; | ||||
| 
 | ||||
|     protected /* ? mixed */ $value; | ||||
| 
 | ||||
|     protected string $name; | ||||
| 
 | ||||
|     public function parse(\Picea\Compiler\Context &$context, ?string $arguments, string $token) : string | ||||
|     { | ||||
|         $opt = $context->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); | ||||
|     } | ||||
| } | ||||
| @ -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", | ||||
|  | ||||
| @ -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", | ||||
|  | ||||
| @ -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", | ||||
|  | ||||
| @ -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", | ||||
|  | ||||
| @ -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", | ||||
|  | ||||
| @ -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", | ||||
|  | ||||
| @ -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 "</form>"; | ||||
|         } | ||||
| 
 | ||||
|             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 "<?php echo ( new \\" . static::class . "() )->buildHtml('$method', $arguments) ?>"; | ||||
| 
 | ||||
|         return "<?php echo ( new \\" . static::class . "() )->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]); | ||||
|  | ||||
| @ -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", | ||||
|  | ||||
| @ -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"; | ||||
| 
 | ||||
|  | ||||
| @ -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"; | ||||
| 
 | ||||
|  | ||||
| @ -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", | ||||
|  | ||||
| @ -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", | ||||
|  | ||||
| @ -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", | ||||
|  | ||||
| @ -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", | ||||
|  | ||||
| @ -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", | ||||
|  | ||||
| @ -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"; | ||||
| 
 | ||||
|  | ||||
| @ -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", | ||||
|  | ||||
| @ -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", | ||||
|  | ||||
| @ -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 "<?php echo ( new \\" . static::class . "() )->echoRaw($raw)->buildHtml($arguments) ?>"; | ||||
|     } | ||||
|  | ||||
| @ -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", | ||||
|  | ||||
| @ -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", | ||||
|  | ||||
| @ -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", | ||||
|  | ||||
| @ -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()); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user