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
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].
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.
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.
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.
Copy file name to clipboardExpand all lines: forms/en/controls.texy
+41Lines changed: 41 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -259,6 +259,47 @@ Do not trust the original file names returned by method `FileUpload::getName()`,
259
259
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].
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.
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].
->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.
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.
0 commit comments