1 <?php
2
3 4 5 6 7
8
9 namespace nk2580\wordsmith\Inputs\Fields;
10
11 use nk2580\wordsmith\Inputs\Input as Input;
12
13 14 15 16 17
18 class EmailField extends Input {
19
20 public function printField() {
21 $class = $this->getClassString();
22 if (!$this->readonly) {
23 echo'<label for="'.$this->name.'">'.$this->label.'<input type="email" class="'.$class.'" id="'.$this->name.'" value="'.$this->value.'" /></label>';
24 } else {
25 echo'<label for="'.$this->name.'">'.$this->label.'<input type="email" readonly class="'.$class.'" id="'.$this->name.'" value="'.$this->value.'" /></label>';
26 }
27 echo '<br/>';
28 }
29
30 public function isFieldValid() {
31 if (filter_var($this->value, FILTER_VALIDATE_EMAIL)) {
32 return true;
33 } else {
34 return false;
35 }
36 }
37
38 public function sanitize() {
39 return ($this->value);
40 }
41
42 }
43