- Corrected inputs handling from view to compiled states

- Added UiSelect widget
- Fixed UiForm widget
- Fixed UiInput widget
- Added mocks of UiMessage and UiPopup. Not even a WIP at this stage.
This commit is contained in:
mcndave committed 2019-11-01 14:47:54 -04:00
1 parent 4bf08def27
commit f28ace745d
7 files changed
+153 -27

No files matched your search

+26 -20
View 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" ];
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";
@@ -21,33 +21,39 @@ class UiForm extends UiElement implements Extension {
public function parse(/*\Picae\Compiler\Context*/ &$context, ?string $arguments, string $token) : string
{
if ( $token === 'ui.endform' ) {
return "</form>";
}
list($action, $options) = array_pad(explode(',', $arguments), 2, null);
$action = $this->trim($action);
switch($token) {
case 'ui.endform':
return "</form>";
case "ui.form.get":
$this->attributes['method'] = "get";
$method = "get";
break;
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":
$this->attributes['method'] = "post";
$this->attributes['enctype'] = "multipart/form-data";
break;
default:
case $this->token:
$this->attributes['method'] = $this->defaultMethod;
$method = "post";
break;
}
$method ??= $this->defaultMethod;
return "<?php echo ( new \\" . static::class . "() )->buildHtml('$method', $arguments) ?>";
}
public function buildHtml(string $method, string $action, array $attributes = []) : string
{
$this->option('tag-type', 'single');
$this->attributes['action'] = $this->trim($action);
$this->attributes($this->parseOptions($options));
return $this->render();
$this->attributes([ 'action' => $action ] + $attributes);
return $this->render() . PHP_EOL;
}
}