Add date and time
This commit is contained in:
parent
aa2449bc16
commit
8f3ce0ad85
|
@ -34,6 +34,18 @@ class Input extends Element{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function date(): Input{
|
||||||
|
$this->data['type'] = 'date';
|
||||||
|
$this->data['date'] = true;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function time(): Input{
|
||||||
|
$this->data['type'] = 'time';
|
||||||
|
$this->data['time'] = true;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function min(int $value) : Input{
|
public function min(int $value) : Input{
|
||||||
$this->data['min'] = $value;
|
$this->data['min'] = $value;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -105,6 +117,18 @@ class Input extends Element{
|
||||||
}else if(isset($this->data['number'])){
|
}else if(isset($this->data['number'])){
|
||||||
if($this->data['number'] == true && !ctype_digit($data))
|
if($this->data['number'] == true && !ctype_digit($data))
|
||||||
return 'non numérique';
|
return 'non numérique';
|
||||||
|
}else if(isset($this->data['date'])){
|
||||||
|
if($this->data['date'] == true){
|
||||||
|
$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);
|
||||||
|
if(!$t || $t->format('H:i') != $data)
|
||||||
|
return 'incorrect';
|
||||||
|
}
|
||||||
}else if(isset($this->data['min'])){
|
}else if(isset($this->data['min'])){
|
||||||
if($data < $this->data['min'])
|
if($data < $this->data['min'])
|
||||||
return 'trop petit';
|
return 'trop petit';
|
||||||
|
|
Loading…
Reference in New Issue