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 | * Displayed or not the field in the columns. |
||
29 | * |
||
30 | * @var bool |
||
31 | */ |
||
32 | protected $columnize = true; |
||
33 | |||
34 | /** |
||
35 | * Set a custom label for the field. |
||
36 | * |
||
37 | * @param string $name |
||
38 | * @return self |
||
39 | */ |
||
40 | public function withLabel($name) |
||
46 | |||
47 | /** |
||
48 | * Defines a placeholder for the field. |
||
49 | * |
||
50 | * @param string $placeholder |
||
51 | * @return self |
||
52 | */ |
||
53 | public function withPlaceholder($placeholder) |
||
59 | |||
60 | /** |
||
61 | * Appends an help message to the input. |
||
62 | * |
||
63 | * @param string $help |
||
64 | * @return self |
||
65 | */ |
||
66 | public function withHelp($help) |
||
72 | |||
73 | /** |
||
74 | * Returns the field's label. |
||
75 | * |
||
76 | * @param void |
||
77 | * @return string |
||
78 | */ |
||
79 | public function getLabel() |
||
88 | |||
89 | /** |
||
90 | * Returns the field's placeholder. |
||
91 | * |
||
92 | * @param void |
||
93 | * @return string |
||
94 | */ |
||
95 | public function getPlaceholder() |
||
104 | |||
105 | /** |
||
106 | * Returns the field's help. |
||
107 | * |
||
108 | * @param void |
||
109 | * @return string |
||
110 | */ |
||
111 | public function getHelp() |
||
120 | |||
121 | /** |
||
122 | * @param bool $state |
||
123 | * @return self |
||
124 | */ |
||
125 | public function displayInColumns($state = true) |
||
131 | |||
132 | /** |
||
133 | * @param void |
||
134 | * @return bool |
||
135 | */ |
||
136 | public function isDisplayedInColumns() |
||
140 | |||
141 | /** |
||
142 | * Return fields specific scripts files from public folder. |
||
143 | * Example: ['js/field.js'] |
||
144 | * |
||
145 | * @param void |
||
146 | * @return array |
||
147 | */ |
||
148 | public function getScripts() |
||
152 | |||
153 | /** |
||
154 | * Return fields specific stylesheets files from public folder. |
||
155 | * Example: ['css/field.css'] |
||
156 | * |
||
157 | * @param void |
||
158 | * @return array |
||
159 | */ |
||
160 | public function getCss() |
||
164 | } |
||
165 |
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: