- Fixed invalid elements after testing

This commit is contained in:
mcndave committed 2019-10-04 08:39:22 -04:00
1 parent a0bf505377
commit 4bf08def27
5 files changed
+73 -68

No files matched your search

+6 -17
View File
@@ -4,8 +4,10 @@ namespace Picea\Ui\Form;
use Picea\Ui\Common\UiElement;
use Picea\Extension\Extension;
use Picea\Extension\ExtensionTrait;
class UiInput extends UiElement implements Extension {
use ExtensionTrait;
public string $token = "ui.input";
@@ -19,29 +21,16 @@ class UiInput extends UiElement implements Extension {
{
list($name, $value, $options) = array_pad(explode(',', $arguments), 3, null);
$this->attributes['name'] = $name;
$this->setValue($value);
$this->attributes($this->parseAttributes($options));
$this->attributes['name'] = $this->trim($name);
$this->setValue($this->trim($value));
$this->attributes($this->parseOptions($options));
return $this->render();
}
protected function parseAttributes(string $options) : array
{
if ( $options ?? false ) {
$attributes = eval($options);
if ( ! is_array($attributes) ) {
throw new InvalidArgumentException("Given options `$options` is not a valid attributes array.");
}
return $attributes;
}
return [];
}
protected function setValue($value) : void
{
$this->attributes['value'] = $value;
}
}