Date/DateTime control for Nette Framework
- Nette >=2.3.0 (2.3.x support will be removed on 31 Jan 2017)
- PHP >=5.5.0 (5.5.x support will be removed on 10 Jul 2016)
composer require nella/forms-datetime
$form = new \Nette\Forms\Form;
$form->addComponent(new \Nella\Forms\DateTime\DateInput('Date'), 'date');
$form->addComponent(new \Nella\Forms\DateTime\DateTimeInput('DateTime'), 'datetime');
// or
\Nella\Forms\DateTime\DateInput::register();
$form->addDate('date', 'Date', 'Y-m-d');
\Nella\Forms\DateTime\DateTimeInput::register();
$form->addDateTime('datetime', 'DateTime', 'Y-m-d', 'G:i');
// Optional date[time] validation
$form['date']
->addCondition(\Nette\Application\UI\Form::FILLED)
->addRule([$form['date'], 'validateDate'], 'Date is invalid');
$form['datetime']
->addCondition(\Nette\Application\UI\Form::FILLED)
->addRule([$form['datetime'], 'validateDateTime'], 'Date time is invalid');
{form myForm}
{label date /}
{input date}
{label datetime /}
{input datetime:date}
{input datetime:time}
{/form}
Date/DateTime control for Nette Framework is licensed under the MIT License - see the LICENSE file for details