Form sets and some fixs

This commit is contained in:
sheychen 2018-05-07 14:11:15 +02:00
parent 8f3ce0ad85
commit cac8a068a0
4 changed files with 8 additions and 8 deletions

View File

@ -17,7 +17,7 @@ class Element{
public function name() : string{ return $this->data['name']; } public function name() : string{ return $this->data['name']; }
public function id(string $id): self{ public function id(string $id): self{
$this->data['id'] = $name; $this->data['id'] = $id;
return $this; return $this;
} }

View File

@ -12,10 +12,11 @@ class Form {
private $errors = array(); private $errors = array();
private $set = false; 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; $this->name = $name;
$tpl = new Html($path, $extention, $folder); $tpl = new Html($path, $extention, $folder);
$tpl->set($name, $this) $tpl->set($name, $this)
->sets($sets)
->run('buffer'); ->run('buffer');
return $this; return $this;
} }

View File

@ -46,12 +46,12 @@ class Input extends Element{
return $this; return $this;
} }
public function min(int $value) : Input{ public function min(string $value) : Input{
$this->data['min'] = $value; $this->data['min'] = $value;
return $this; return $this;
} }
public function max(int $value) : Input{ public function max(string $value) : Input{
$this->data['max'] = $value; $this->data['max'] = $value;
return $this; return $this;
} }
@ -119,13 +119,13 @@ class Input extends Element{
return 'non numérique'; return 'non numérique';
}else if(isset($this->data['date'])){ }else if(isset($this->data['date'])){
if($this->data['date'] == true){ 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) if(!$d || $d->format('Y-m-d') != $data)
return 'incorrect'; return 'incorrect';
} }
}else if(isset($this->data['time'])){ }else if(isset($this->data['time'])){
if($this->data['time'] == true){ if($this->data['time'] == true){
$t = DateTime::createFromFormat('H:i', $data); $t = \DateTime::createFromFormat('H:i', $data);
if(!$t || $t->format('H:i') != $data) if(!$t || $t->format('H:i') != $data)
return 'incorrect'; return 'incorrect';
} }

View File

@ -11,8 +11,7 @@ class TextArea extends Element{
return $this->htmlLabel(). return $this->htmlLabel().
'<textarea name="'.$this->data['name'].'" '. '<textarea name="'.$this->data['name'].'" '.
'id="'.$this->getId().'" '. 'id="'.$this->getId().'" '.
(isset($this->data['value']) ? 'value="'.$this->data['value'].'" ' : '').
(isset($this->data['required']) && $this->data['required'] == true ? 'required ' : ''). (isset($this->data['required']) && $this->data['required'] == true ? 'required ' : '').
$more.'></textarea>'; $more.'>'.(isset($this->data['value']) ? $this->data['value'] : '').'</textarea>';
} }
} }