1 <?php
2
3 4 5 6 7
8
9 namespace nk2580\wordsmith\Inputs;
10
11 class Input {
12
13 protected $name;
14 protected $class = "";
15 protected $readonly;
16 protected $value;
17 protected $label;
18
19 public function __construct($name, $label = '', $value = '', $class = '', $readonly = false) {
20 $this->name = $name;
21 $this->class = $class;
22 $this->value = $value;
23 $this->label = $label;
24 $this->readonly = $readonly;
25 }
26
27 public function printField() {
28 echo "Implementing the Input class directly is foribbben. please use an input field or type";
29 }
30
31 public function isFieldValid() {
32 return true;
33 }
34
35 public function sanitize() {
36 return $this->value;
37 }
38
39 protected function getClassString() {
40 $string = "";
41 if (is_array($this->class)) {
42 foreach ($this->class as $class) {
43 $string .= $class . " ";
44 }
45 return $string;
46 } else if (empty($this->class)) {
47 return $string;
48 } else {
49 return $this->class;
50 }
51 }
52 }
53