1 | <?php |
||
10 | trait FieldHasUiModifiers |
||
11 | { |
||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | protected $label; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $placeholder; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $help; |
||
26 | |||
27 | /** |
||
28 | * Set a custom label for the field. |
||
29 | * |
||
30 | * @param string $name |
||
31 | * @return self |
||
32 | */ |
||
33 | public function withLabel($name) |
||
39 | |||
40 | /** |
||
41 | * Defines a placeholder for the field. |
||
42 | * |
||
43 | * @param string $placeholder |
||
44 | * @return self |
||
45 | */ |
||
46 | public function withPlaceholder($placeholder) |
||
52 | |||
53 | /** |
||
54 | * Appends an help message to the input. |
||
55 | * |
||
56 | * @param string $help |
||
57 | * @return self |
||
58 | */ |
||
59 | public function withHelp($help) |
||
65 | |||
66 | /** |
||
67 | * Returns the field's label. |
||
68 | * |
||
69 | * @param void |
||
70 | * @return string |
||
71 | */ |
||
72 | public function getLabel() |
||
81 | |||
82 | /** |
||
83 | * Returns the field's placeholder. |
||
84 | * |
||
85 | * @param void |
||
86 | * @return string |
||
87 | */ |
||
88 | public function getPlaceholder() |
||
97 | |||
98 | /** |
||
99 | * Returns the field's help. |
||
100 | * |
||
101 | * @param void |
||
102 | * @return string |
||
103 | */ |
||
104 | public function getHelp() |
||
113 | |||
114 | /** |
||
115 | * Return fields specific scripts files from public folder. |
||
116 | * Example: ['js/field.js'] |
||
117 | * |
||
118 | * @param void |
||
119 | * @return array |
||
120 | */ |
||
121 | public function getScripts() |
||
125 | |||
126 | /** |
||
127 | * Return fields specific stylesheets files from public folder. |
||
128 | * Example: ['css/field.css'] |
||
129 | * |
||
130 | * @param void |
||
131 | * @return array |
||
132 | */ |
||
133 | public function getCss() |
||
137 | } |
||
138 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: