nextras / form-components

Form components for Nette Framework (architecture & UI components)
Other
11 stars 3 forks source link

usage in form rules #4

Open Ciki opened 3 years ago

Ciki commented 3 years ago

Hi, how can I use datepicker control in form rule as in example below? The date_from control's getValue() return DateTimeImmutable instance which does not have __toString() implemented thus throws an error in Nette\Forms\Validator::formatMessage()

$form->addDatePicker('date_from', 'Dátum od');
$form->addDatePicker('date_to', 'Dátum do')
  ->addRule($form::RANGE, 'Please select date between %d and %d', [$form['date_from'], new \Nette\Utils\DateTime()]);

Thanks!

Ciki commented 2 years ago

how do you use it? anyone...?