From cac8a068a0c6b5ac10ead67e3a2a89bdd0fa0904 Mon Sep 17 00:00:00 2001 From: sheychen Date: Mon, 7 May 2018 14:11:15 +0200 Subject: [PATCH] Form sets and some fixs --- src/Element.php | 2 +- src/Form.php | 3 ++- src/Input.php | 8 ++++---- src/TextArea.php | 3 +-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Element.php b/src/Element.php index 82f289a..b2cac35 100644 --- a/src/Element.php +++ b/src/Element.php @@ -17,7 +17,7 @@ class Element{ public function name() : string{ return $this->data['name']; } public function id(string $id): self{ - $this->data['id'] = $name; + $this->data['id'] = $id; return $this; } diff --git a/src/Form.php b/src/Form.php index 978928c..328425f 100644 --- a/src/Form.php +++ b/src/Form.php @@ -12,10 +12,11 @@ class Form { private $errors = array(); private $set = false; - public function __construct(string $name, string $path, string $extention = null, bool $folder = true){ + public function __construct(string $name, string $path, string $extention = null, bool $folder = true, array $sets = array()){ $this->name = $name; $tpl = new Html($path, $extention, $folder); $tpl->set($name, $this) + ->sets($sets) ->run('buffer'); return $this; } diff --git a/src/Input.php b/src/Input.php index 698d4d1..f701d90 100644 --- a/src/Input.php +++ b/src/Input.php @@ -46,12 +46,12 @@ class Input extends Element{ return $this; } - public function min(int $value) : Input{ + public function min(string $value) : Input{ $this->data['min'] = $value; return $this; } - public function max(int $value) : Input{ + public function max(string $value) : Input{ $this->data['max'] = $value; return $this; } @@ -119,13 +119,13 @@ class Input extends Element{ return 'non numérique'; }else if(isset($this->data['date'])){ if($this->data['date'] == true){ - $d = DateTime::createFromFormat('Y-m-d', $data); + $d = \DateTime::createFromFormat('Y-m-d', $data); if(!$d || $d->format('Y-m-d') != $data) return 'incorrect'; } }else if(isset($this->data['time'])){ if($this->data['time'] == true){ - $t = DateTime::createFromFormat('H:i', $data); + $t = \DateTime::createFromFormat('H:i', $data); if(!$t || $t->format('H:i') != $data) return 'incorrect'; } diff --git a/src/TextArea.php b/src/TextArea.php index 6df7e3d..a8eb169 100644 --- a/src/TextArea.php +++ b/src/TextArea.php @@ -11,8 +11,7 @@ class TextArea extends Element{ return $this->htmlLabel(). ''; + $more.'>'.(isset($this->data['value']) ? $this->data['value'] : '').''; } } \ No newline at end of file