You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/php/api/form_builder/form_fields.md
+12-65Lines changed: 12 additions & 65 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,14 +2,12 @@
2
2
3
3
## Abstract Form Fields
4
4
5
-
The following form field classes cannot be instantiated directly because they are abstract, but they can/must be used when creating own form field classes.
6
-
5
+
The following form field classes cannot be instantiated directly because they are abstract, but they can/must be used when creating own form field classes.
7
6
8
7
### `AbstractFormField`
9
8
10
9
`AbstractFormField` is the abstract default implementation of the `IFormField` interface and it is expected that every implementation of `IFormField` implements the interface by extending this class.
11
10
12
-
13
11
### `AbstractNumericFormField`
14
12
15
13
`AbstractNumericFormField` is the abstract implementation of a form field handling a single numeric value.
@@ -31,22 +29,19 @@ If the implementation of a more specific interface is required then the remainin
31
29
32
30
The following form fields are general reusable fields without any underlying context.
33
31
34
-
35
32
### `BooleanFormField`
36
33
37
34
`BooleanFormField` is used for boolean (`0` or `1`, `yes` or `no`) values.
38
35
Objects of this class require a label.
39
36
The return value of `getSaveValue()` is the integer representation of the boolean value, i.e. `0` or `1`.
40
37
The class implements `IAttributeFormField`, `IAutoFocusFormField`, `ICssClassFormField`, and `IImmutableFormField`.
41
38
42
-
43
39
### `CheckboxFormField`
44
40
45
41
!!! info "Only available since version 5.3.2."
46
42
47
43
`CheckboxFormField` extends `BooleanFormField` and offers a simple HTML checkbox.
48
44
49
-
50
45
### `ClassNameFormField`
51
46
52
47
`ClassNameFormField` is a [text form field](#textformfield) that supports additional settings, specific to entering a PHP class name:
@@ -62,7 +57,6 @@ The class implements `IAttributeFormField`, `IAutoFocusFormField`, `ICssClassFor
62
57
63
58
Additionally, the default id of a `ClassNameFormField` object is `className`, the default label is `wcf.form.field.className`, and if either an interface or a parent class is required, a default description is set if no description has already been set (`wcf.form.field.className.description.interface` and `wcf.form.field.className.description.parentClass`, respectively).
64
59
65
-
66
60
### `DateFormField`
67
61
68
62
`DateFormField` is a form field to enter a date (and optionally a time).
@@ -78,45 +72,37 @@ The following methods are specific to this form field class:
78
72
-`supportTime($supportsTime = true)` and `supportsTime()` can be used to toggle whether, in addition to a date, a time can also be specified.
79
73
By default, specifying a time is disabled.
80
74
81
-
82
75
### `DescriptionFormField`
83
76
84
77
`DescriptionFormField` is a [multi-line text form field](#multilinetextformfield) with `description` as the default id and `wcf.global.description` as the default label.
85
78
86
-
87
79
### `EmailFormField`
88
80
89
81
`EmailFormField` is a form field to enter an email address which is internally validated using `UserUtil::isValidEmail()`.
90
82
The class implements `IAttributeFormField`, `IAutoCompleteFormField`, `IAutoFocusFormField`, `ICssClassFormField`, `II18nFormField`, `IImmutableFormField`, `IInputModeFormField`, `IPatternFormField`, and `IPlaceholderFormField`.
91
83
92
-
93
84
### `FloatFormField`
94
85
95
86
`FloatFormField` is an implementation of [AbstractNumericFormField](#abstractnumericformfield) for floating point numbers.
96
87
97
-
98
88
### `HiddenFormField`
99
89
100
90
`HiddenFormField` is a form field without any user-visible UI.
101
91
Even though the form field is invisible to the user, the value can still be modified by the user, e.g. by leveraging the web browsers developer tools.
102
-
The `HiddenFormField`*must not* be used to transfer sensitive information or information that the user should not be able to modify.
103
-
92
+
The `HiddenFormField`_must not_ be used to transfer sensitive information or information that the user should not be able to modify.
104
93
105
94
### `IconFormField`
106
95
107
96
`IconFormField` is a form field to select a FontAwesome icon.
108
97
109
-
110
98
### `IntegerFormField`
111
99
112
100
`IntegerFormField` is an implementation of [AbstractNumericFormField](#abstractnumericformfield) for integers.
113
101
114
-
115
102
### `IsDisabledFormField`
116
103
117
104
`IsDisabledFormField` is a [boolean form field](#booleanformfield) with `isDisabled` as the default id.
118
105
119
-
120
106
### `ItemListFormField`
121
107
122
108
`ItemListFormField` is a form field in which multiple values can be entered and returned in different formats as save value.
@@ -133,28 +119,23 @@ By default, `ItemListFormField::SAVE_VALUE_TYPE_CSV` is used.
133
119
134
120
If `ItemListFormField::SAVE_VALUE_TYPE_ARRAY` is used as save value type, `ItemListFormField` objects register a [custom form field data processor](validation_data.md#customformfielddataprocessor) to add the relevant array into the `$parameters` array directly using the object property as the array key.
135
121
136
-
137
122
### `MultilineTextFormField`
138
123
139
124
`MultilineTextFormField` is a [text form field](#textformfield) that supports multiple rows of text.
140
125
The methods `rows($rows)` and `getRows()` can be used to set and get the number of rows of the `textarea` elements.
141
126
The default number of rows is `10`.
142
127
These methods do **not**, however, restrict the number of text rows that can be entered.
143
128
144
-
145
129
### `MultipleSelectionFormField`
146
130
147
131
`MultipleSelectionFormField` is a form fields that allows the selection of multiple options out of a predefined list of available options.
148
-
The class implements `IAttributeFormField`, `ICssClassFormField`, `IFilterableSelectionFormField`, `IImmutableFormField`, and `INullableFormField`.
149
-
If the field is nullable and no option is selected, `null` is returned as the save value.
150
-
132
+
The class implements `IAttributeFormField`, `ICssClassFormField`, `IFilterableSelectionFormField`, `IImmutableFormField`.
151
133
152
134
### `RadioButtonFormField`
153
135
154
136
`RadioButtonFormField` is a form fields that allows the selection of a single option out of a predefined list of available options using radiobuttons.
155
137
The class implements `IAttributeFormField`, `ICssClassFormField`, `IImmutableFormField`, and `ISelectionFormField`.
156
138
157
-
158
139
### `RatingFormField`
159
140
160
141
`RatingFormField` is a form field to set a rating for an object.
@@ -163,8 +144,7 @@ Form fields of this class have `rating` as their default id, `wcf.form.field.rat
163
144
For this field, the minimum and maximum refer to the minimum and maximum rating an object can get.
164
145
When the field is shown, there will be `maximum() - minimum() + 1` icons be shown with additional CSS classes that can be set and gotten via `defaultCssClasses(array $cssClasses)` and `getDefaultCssClasses()`.
165
146
If a rating values is set, the first `getValue()` icons will instead use the classes that can be set and gotten via `activeCssClasses(array $cssClasses)` and `getActiveCssClasses()`.
166
-
By default, the only default class is `fa-star-o` and the active classes are `fa-star` and `orange`.
167
-
147
+
By default, the only default class is `fa-star-o` and the active classes are `fa-star` and `orange`.
168
148
169
149
### `ShowOrderFormField`
170
150
@@ -175,41 +155,33 @@ The default id of instances of this class is `showOrder` and their default label
175
155
176
156
!!! info "It is important that the relevant object property is always kept updated. Whenever a new object is added or an existing object is edited or delete, the values of the other objects have to be adjusted to ensure consecutive numbering."
177
157
178
-
179
158
### `SingleSelectionFormField`
180
159
181
160
`SingleSelectionFormField` is a form fields that allows the selection of a single option out of a predefined list of available options.
182
161
The class implements `ICssClassFormField`, `IFilterableSelectionFormField`, `IImmutableFormField`, and `INullableFormField`.
183
162
If the field is nullable and the current form field value is considered `empty` by PHP, `null` is returned as the save value.
184
163
185
-
186
164
### `SortOrderFormField`
187
165
188
166
`SingleSelectionFormField` is a [single selection form field](#singleselectionformfield) with default id `sortOrder`, default label `wcf.global.showOrder` and default options `ASC: wcf.global.sortOrder.ascending` and `DESC: wcf.global.sortOrder.descending`.
189
167
190
-
191
168
### `TextFormField`
192
169
193
170
`TextFormField` is a form field that allows entering a single line of text.
194
171
The class implements `IAttributeFormField`, `IAutoCompleteFormField`, `ICssClassFormField`, `IImmutableFormField`, `II18nFormField`, `IInputModeFormField`, `IMaximumLengthFormField`, `IMinimumLengthFormField`, `IPatternFormField`, and `IPlaceholderFormField`.
195
172
196
-
197
173
### `TitleFormField`
198
174
199
175
`TitleFormField` is a [text form field](#textformfield) with `title` as the default id and `wcf.global.title` as the default label.
200
176
201
-
202
177
### `UrlFormField`
203
178
204
179
`UrlFormField` is a [text form field](#textformfield) whose values are checked via `Url::is()`.
205
180
206
-
207
-
208
181
## Specific Fields
209
182
210
183
The following form fields are reusable fields that generally are bound to a certain API or `DatabaseObject` implementation.
211
184
212
-
213
185
### `AclFormField`
214
186
215
187
`AclFormField` is used for setting up acl values for specific objects.
@@ -222,39 +194,34 @@ A category name of `null` signals that no category filter is used.
222
194
`AclFormField` objects register a [custom form field data processor](validation_data.md#customformfielddataprocessor) to add the relevant ACL object type id into the `$parameters` array directly using `{$objectProperty}_aclObjectTypeID` as the array key.
223
195
The relevant database object action method is expected, based on the given ACL object type id, to save the ACL option values appropriately.
224
196
225
-
226
197
### `ButtonFormField`
227
198
228
199
!!! info "Only available since version 5.4."
229
200
230
201
`ButtonFormField` shows a submit button as part of the form.
231
202
The class implements `IAttributeFormField` and `ICssClassFormField`.
232
203
233
-
Specifically for this form field, there is the `IsNotClickedFormFieldDependency` dependency with which certain parts of the form will only be processed if the relevent button has not clicked.
234
-
204
+
Specifically for this form field, there is the `IsNotClickedFormFieldDependency` dependency with which certain parts of the form will only be processed if the relevent button has not clicked.
235
205
236
206
### `CaptchaFormField`
237
207
238
208
`CaptchaFormField` is used to add captcha protection to the form.
239
209
240
210
You must specify a captcha object type (`com.woltlab.wcf.captcha`) using the `objectType()` method.
241
211
242
-
243
212
### `ColorFormField`
244
213
245
214
!!! info "Only available since version 5.5."
246
215
247
216
`ColorFormField` is used to specify RGBA colors using the `rgba(r, g, b, a)` format.
248
217
The class implements `IImmutableFormField`.
249
218
250
-
251
219
### `ContentLanguageFormField`
252
220
253
221
`ContentLanguageFormField` is used to select the content language of an object.
254
-
Fields of this class are only available if multilingualism is enabled and if there are content languages.
222
+
Fields of this class are only available if multilingualism is enabled and if there are content languages.
255
223
The class implements `IImmutableFormField`.
256
224
257
-
258
225
### `LabelFormField`
259
226
260
227
`LabelFormField` is used to select a label from a specific label group.
@@ -264,14 +231,12 @@ The `labelGroup(ViewableLabelGroup $labelGroup)` and `getLabelGroup()` methods a
264
231
Additionally, there is the static method `createFields($objectType, array $labelGroups, $objectProperty = 'labelIDs)` that can be used to create all relevant label form fields for a given list of label groups.
265
232
In most cases, `LabelFormField::createFields()` should be used.
266
233
267
-
268
234
### `OptionFormField`
269
235
270
236
`OptionFormField` is an [item list form field](#itemlistformfield) to set a list of options.
271
237
The class implements `IPackagesFormField` and only options of the set packages are considered available.
272
238
The default label of instances of this class is `wcf.form.field.option` and their default id is `options`.
273
239
274
-
275
240
### `SimpleAclFormField`
276
241
277
242
`SimpleAclFormField` is used for setting up simple acl values (one `yes`/`no` option per user and user group) for specific objects.
@@ -292,7 +257,6 @@ The following methods are specific to this form field class:
292
257
-`imageOnly($imageOnly = true)` and `isImageOnly()` can be used to set and check if only images may be selected.
293
258
-`getMedia()` returns the media file based on the current field value if a field is set.
294
259
295
-
296
260
### `TagFormField`
297
261
298
262
`TagFormField` is a form field to enter tags.
@@ -302,57 +266,51 @@ The default label of instances of this class is `wcf.tagging.tags` and their def
302
266
303
267
`TagFormField` objects register a [custom form field data processor](validation_data.md#customformfielddataprocessor) to add the array with entered tag names into the `$parameters` array directly using the object property as the array key.
304
268
305
-
306
269
### `UploadFormField`
307
270
308
271
`UploadFormField` is a form field that allows uploading files by the user.
309
272
310
-
`UploadFormField` objects register a [custom form field data processor](validation_data.md#customformfielddataprocessor) to add the array of `wcf\system\file\upload\UploadFile\UploadFile` into the `$parameters` array directly using the object property as the array key. Also it registers the removed files as an array of `wcf\system\file\upload\UploadFile\UploadFile` into the `$parameters` array directly using the object property with the suffix `_removedFiles` as the array key.
273
+
`UploadFormField` objects register a [custom form field data processor](validation_data.md#customformfielddataprocessor) to add the array of `wcf\system\file\upload\UploadFile\UploadFile` into the `$parameters` array directly using the object property as the array key. Also it registers the removed files as an array of `wcf\system\file\upload\UploadFile\UploadFile` into the `$parameters` array directly using the object property with the suffix `_removedFiles` as the array key.
274
+
275
+
The field supports additional settings:
311
276
312
-
The field supports additional settings:
313
277
-`imageOnly($imageOnly = true)` and `isImageOnly()` can be used to ensure that the uploaded files are only images.
314
278
-`allowSvgImage($allowSvgImages = true)` and `svgImageAllowed()` can be used to allow SVG images, if the image only mode is enabled (otherwise, the method will throw an exception). By default, SVG images are not allowed.
315
279
316
-
#### Provide value from database object
280
+
#### Provide value from database object
317
281
318
282
To provide values from a database object, you should implement the method `get{$objectProperty}UploadFileLocations()` to your database object class. This method must return an array of strings with the locations of the files.
319
283
320
-
#### Process files
284
+
#### Process files
321
285
322
286
To process files in the database object action class, you must [`rename`](https://secure.php.net/manual/en/function.rename.php) the file to the final destination. You get the temporary location, by calling the method `getLocation()` on the given `UploadFile` objects. After that, you call `setProcessed($location)` with `$location` contains the new file location. This method sets the `isProcessed` flag to true and saves the new location. For updating files, it is relevant, whether a given file is already processed or not. For this case, the `UploadFile` object has an method `isProcessed()` which indicates, whether a file is already processed or new uploaded.
323
287
324
-
325
288
### `UserFormField`
326
289
327
290
`UserFormField` is a form field to enter existing users.
328
291
The class implements `IAutoCompleteFormField`, `IAutoFocusFormField`, `IImmutableFormField`, `IMultipleFormField`, and `INullableFormField`.
329
292
While the user is presented the names of the specified users in the user interface, the field returns the ids of the users as data.
330
293
The relevant `UserProfile` objects can be accessed via the `getUsers()` method.
331
294
332
-
333
295
### `UserPasswordField`
334
296
335
297
!!! info "Only available since version 5.4."
336
298
337
299
`UserPasswordField` is a form field for users' to enter their current password.
338
300
The class implements `IAttributeFormField`, `IAttributeFormField`, `IAutoCompleteFormField`, `IAutoFocusFormField`, and `IPlaceholderFormField`
339
301
340
-
341
302
### `UserGroupOptionFormField`
342
303
343
304
`UserGroupOptionFormField` is an [item list form field](#itemlistformfield) to set a list of user group options/permissions.
344
305
The class implements `IPackagesFormField` and only user group options of the set packages are considered available.
345
306
The default label of instances of this class is `wcf.form.field.userGroupOption` and their default id is `permissions`.
346
307
347
-
348
308
### `UsernameFormField`
349
309
350
310
`UsernameFormField` is used for entering one non-existing username.
351
311
The class implements `IAttributeFormField`, `IImmutableFormField`, `IMaximumLengthFormField`, `IMinimumLengthFormField`, `INullableFormField`, and `IPlaceholderFormField`.
352
312
As usernames have a system-wide restriction of a minimum length of 3 and a maximum length of 100 characters, these values are also used as the default value for the field’s minimum and maximum length.
353
313
354
-
355
-
356
314
## Wysiwyg form container
357
315
358
316
To integrate a wysiwyg editor into a form, you have to create a `WysiwygFormContainer` object.
`WysiwygFormField` is used for wysiwyg editor form fields.
@@ -449,20 +406,17 @@ The following methods are specific to this form field class:
449
406
`0` signals that no last edit time has been set.
450
407
-`supportAttachments($supportAttachments)` and `supportsAttachments()` can be used to set and check if the form field supports attachments.
451
408
452
-
!!! warning "It is not sufficient to simply signal attachment support via these methods for attachments to work. These methods are relevant internally to signal the Javascript code that the editor supports attachments. Actual attachment support is provided by `WysiwygAttachmentFormField`."
409
+
!!! warning "It is not sufficient to simply signal attachment support via these methods for attachments to work. These methods are relevant internally to signal the Javascript code that the editor supports attachments. Actual attachment support is provided by `WysiwygAttachmentFormField`."
453
410
454
411
-`supportMentions($supportMentions)` and `supportsMentions()` can be used to set and check if the form field supports mentions of other users.
455
412
456
413
`WysiwygFormField` objects register a [custom form field data processor](validation_data.md#customformfielddataprocessor) to add the relevant simple ACL data array into the `$parameters` array directly using the object property as the array key.
457
414
458
-
459
415
### `TWysiwygFormNode`
460
416
461
417
All form nodes that need to know the id of the `WysiwygFormField` field should use `TWysiwygFormNode`.
462
418
This trait provides `getWysiwygId()` and `wysiwygId($wysiwygId)` to get and set the relevant wysiwyg editor id.
463
419
464
-
465
-
466
420
## Application-Specific Form Fields
467
421
468
422
### WoltLab Suite Forum
@@ -485,33 +439,26 @@ The field supports additional settings:
485
439
By default, external links are shown.
486
440
Like in the example given before, in cases where only actual boards, in which threads can be posted, are relevant, this option allows to exclude external links.
487
441
488
-
489
-
490
442
## Single-Use Form Fields
491
443
492
444
The following form fields are specific for certain forms and hardly reusable in other contexts.
493
445
494
-
495
446
### `BBCodeAttributesFormField`
496
447
497
448
`DevtoolsProjectExcludedPackagesFormField` is a form field for setting the attributes of a BBCode.
498
449
499
-
500
450
### `DevtoolsProjectExcludedPackagesFormField`
501
451
502
452
`DevtoolsProjectExcludedPackagesFormField` is a form field for setting the excluded packages of a devtools project.
503
453
504
-
505
454
### `DevtoolsProjectInstructionsFormField`
506
455
507
456
`DevtoolsProjectExcludedPackagesFormField` is a form field for setting the installation and update instructions of a devtools project.
508
457
509
-
510
458
### `DevtoolsProjectOptionalPackagesFormField`
511
459
512
460
`DevtoolsProjectExcludedPackagesFormField` is a form field for setting the optional packages of a devtools project.
513
461
514
-
515
462
### `DevtoolsProjectRequiredPackagesFormField`
516
463
517
464
`DevtoolsProjectExcludedPackagesFormField` is a form field for setting the required packages of a devtools project.
0 commit comments