Skip to content

Commit cde3cdb

Browse files
committed
nette/forms 3.1.13
1 parent 1d20b83 commit cde3cdb

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

forms/cs/controls.texy

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,47 @@ Nikdy nevěřte originálním názvům souborů vráceným metodou `FileUpload::
259259
Pravidla `MimeType` a `Image` detekují požadovaný typ na základě signatury souboru a neověřují jeho integritu. Zda není obrázek poškozený lze zjistit například pokusem o jeho [načtení|http:request#toImage].
260260

261261

262+
addDate(string|int $name, $label=null): DateTimeControl .[method]{data-version:3.1.13}
263+
======================================================================================
264+
265+
Přidá políčko, které umožní uživateli snadno zadat datum, včetně roku, měsíce a dne (třída [DateTimeControl |api:Nette\Forms\Controls\DateTimeControl]). Standardně vrací objekt `DateTimeImmutable`, metodou `setFormat()` lze určit [jiný textový formát|https://www.php.net/manual/en/datetime.format.php#refsect1-datetime.format-parameters].
266+
267+
```php
268+
$form->addDate('date', 'Datum:')
269+
->setDefaultValue(new DateTime)
270+
->addRule($form::Min, 'Datum musí být minimálně měsíc staré.', new DateTime('-1 month'));
271+
```
272+
273+
Jako výchozí hodnotu akceptuje kromě objektů s rozhraním DateTimeInterface také řetězec s datumem nebo UNIX timestamp jako číslo. Totéž platí pro argumenty pravidel `Min`, `Max` nebo `Range`, pomocí kterých lze omezit minimální/maximální datum.
274+
275+
276+
addTime(string|int $name, $label=null, bool $withSeconds = false): DateTimeControl .[method]{data-version:3.1.13}
277+
=================================================================================================================
278+
279+
Přidá políčko, které umožní uživateli snadno zadat čas, včetně hodin, minut a volitelně i sekund (třída [DateTimeControl |api:Nette\Forms\Controls\DateTimeControl]). Standardně vrací objekt `DateTimeImmutable`, metodou `setFormat()` lze určit [jiný textový formát|https://www.php.net/manual/en/datetime.format.php#refsect1-datetime.format-parameters].
280+
281+
```php
282+
$form->addTime('time', 'Čas:', withSeconds: true)
283+
->addRule($form::Range, 'Čas musí být v rozsahu od %d do %d.', ['12:30', '13:30']);
284+
```
285+
286+
Jako výchozí hodnotu akceptuje kromě objektů rozhraním DateTimeInterface také řetězec s datumem nebo UNIX timestamp jako číslo. Použije z něj jen časovou informaci bez data. Totéž platí pro argumenty pravidel `Min`, `Max` nebo `Range`, pomocí kterých lze omezit minimální/maximální datum. Nastavením minimální hodnoty větší než maximální se platný časový rozsah obtočí kolem půlnoci a vznikne rozsah, který přesahuje půlnoc.
287+
288+
289+
addDateTime(string|int $name, $label=null, bool $withSeconds = false): DateTimeControl .[method]{data-version:3.1.13}
290+
=====================================================================================================================
291+
292+
Přidá políčko, které umožní uživateli snadno zadat datum a čas, včetně roku, měsíce, dne, hodin, minut a volitelně i sekund (třída [DateTimeControl |api:Nette\Forms\Controls\DateTimeControl]). Standardně vrací objekt `DateTimeImmutable`, metodou `setFormat()` lze určit [jiný textový formát|https://www.php.net/manual/en/datetime.format.php#refsect1-datetime.format-parameters].
293+
294+
```php
295+
$form->addDateTime('datetime', 'Datum a čas:')
296+
->setDefaultValue(new DateTime)
297+
->addRule($form::Min, 'Datum musí být minimálně měsíc staré.', new DateTime('-1 month'));
298+
```
299+
300+
Jako výchozí hodnotu akceptuje kromě objektů s rozhraním DateTimeInterface také řetězec s datumem nebo UNIX timestamp jako číslo. Totéž platí pro argumenty pravidel `Min`, `Max` nebo `Range`, pomocí kterých lze omezit minimální/maximální datum.
301+
302+
262303
addHidden(string|int $name, string $default=null): HiddenField .[method]
263304
========================================================================
264305

forms/en/controls.texy

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,47 @@ Do not trust the original file names returned by method `FileUpload::getName()`,
259259
Rules `MimeType` and `Image` detect required type of file or image by its signature. The integrity of the entire file is not checked. You can find out if an image is not corrupted for example by trying to [load it|http:request#toImage].
260260

261261

262+
addDate(string|int $name, $label=null): DateTimeControl .[method]{data-version:3.1.13}
263+
======================================================================================
264+
265+
Adds a field that allows the user to easily input a date, including year, month, and day (class [DateTimeControl |api:Nette\Forms\Controls\DateTimeControl]). By default, it returns a `DateTimeImmutable` object. The `setFormat()` method can be used to specify a [different text format|https://www.php.net/manual/en/datetime.format.php#refsect1-datetime.format-parameters].
266+
267+
```php
268+
$form->addDate('date', 'Date:')
269+
->setDefaultValue(new DateTime)
270+
->addRule($form::Min, 'The date must be at least a month old.', new DateTime('-1 month'));
271+
```
272+
273+
For the default value, in addition to objects with the DateTimeInterface, it also accepts a date string or a UNIX timestamp as a number. The same applies to the arguments of the `Min`, `Max`, or `Range` rules, which can be used to limit the minimum/maximum date.
274+
275+
276+
addTime(string|int $name, $label=null, bool $withSeconds = false): DateTimeControl .[method]{data-version:3.1.13}
277+
=================================================================================================================
278+
279+
Adds a field that allows the user to easily input time, including hours, minutes, and optionally seconds (class [DateTimeControl |api:Nette\Forms\Controls\DateTimeControl]). By default, it returns a `DateTimeImmutable` object. The `setFormat()` method can be used to specify a [different text format|https://www.php.net/manual/en/datetime.format.php#refsect1-datetime.format-parameters].
280+
281+
```php
282+
$form->addTime('time', 'Time:', withSeconds: true)
283+
->addRule($form::Range, 'Time must be between %d and %d.', ['12:30', '13:30']);
284+
```
285+
286+
For the default value, in addition to objects with the DateTimeInterface, it also accepts a date string or a UNIX timestamp as a number. It will only use the time information without the date. The same applies to the arguments of the `Min`, `Max`, or `Range` rules, which can be used to limit the minimum/maximum date. By setting a minimum value greater than the maximum, the valid time range wraps around midnight, creating a range that spans past midnight.
287+
288+
289+
addDateTime(string|int $name, $label=null, bool $withSeconds = false): DateTimeControl .[method]{data-version:3.1.13}
290+
=====================================================================================================================
291+
292+
Adds a field that allows the user to easily input both date and time, including year, month, day, hours, minutes, and optionally seconds (class [DateTimeControl |api:Nette\Forms\Controls\DateTimeControl]). By default, it returns a `DateTimeImmutable` object. The `setFormat()` method can be used to specify a [different text format|https://www.php.net/manual/en/datetime.format.php#refsect1-datetime.format-parameters].
293+
294+
```php
295+
$form->addDateTime('datetime', 'Date and Time:')
296+
->setDefaultValue(new DateTime)
297+
->addRule($form::Min, 'The date must be at least a month old.', new DateTime('-1 month'));
298+
```
299+
300+
For the default value, in addition to objects with the DateTimeInterface, it also accepts a date string or a UNIX timestamp as a number. The same applies to the arguments of the `Min`, `Max`, or `Range` rules, which can be used to limit the minimum/maximum date.
301+
302+
262303
addHidden(string|int $name, string $default=null): HiddenField .[method]
263304
========================================================================
264305

0 commit comments

Comments
 (0)