Skip to content

Commit 0a2aa05

Browse files
committed
Document DateRangeFormField
Closes #478
1 parent 192ea01 commit 0a2aa05

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/php/api/form_builder/form_fields.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,29 @@ DateFormField::create('example')
120120
->value(DateUtil::format(DateUtil::getDateTimeByTimestamp(TIME_NOW), 'Y-m-d'))
121121
```
122122

123+
### `DateRangeFormField`
124+
125+
`DateRangeFormField` is a form field to enter a date range, consisting of a start and an end date.
126+
The two values are separated by a semicolon in the value.
127+
The class implements `IAttributeFormField`, `IAutoFocusFormField`, `ICssClassFormField`, `IImmutableFormField`, and `INullableFormField`.
128+
129+
The following methods are specific to this form field class:
130+
131+
- `saveValueFormat($saveValueFormat)` and `getSaveValueFormat()` can be used to specify the date format of the value returned by `getSaveValue()`.
132+
By default, `U` is used as format.
133+
The [PHP manual](https://secure.php.net/manual/en/function.date.php) provides an overview of supported formats.
134+
- `supportTime($supportsTime = true)` and `supportsTime()` can be used to toggle whether, in addition to a date, a time can also be specified.
135+
By default, specifying a time is disabled.
136+
137+
Example:
138+
139+
```php
140+
DateRangeFormField::create('example')
141+
->label('foo.bar.example')
142+
->saveValueFormat('Y-m-d')
143+
->value(DateUtil::format(DateUtil::getDateTimeByTimestamp(TIME_NOW - 86_400), 'Y-m-d') . ';' . DateUtil::format(DateUtil::getDateTimeByTimestamp(TIME_NOW), 'Y-m-d'))
144+
```
145+
123146
### `DescriptionFormField`
124147

125148
`DescriptionFormField` is a [multi-line text form field](#multilinetextformfield) with `description` as the default id and `wcf.global.description` as the default label.

0 commit comments

Comments
 (0)