nella/forms-datetime

Date/DateTime control for Nette Forms.

Installs: 655

Dependents: 2

Stars: 2

Watchers: 1

Forks: 1

Language: PHP

v2.3.0 2015-04-20 11:43 UTC

README

Build Status Code Coverage SensioLabsInsight Status Latest Stable Version Composer Downloads Dependency Status HHVM Status

Requirements

  • Nette >=2.2.0 (2.2.x support will be removed on 31 Jan 2016)
  • PHP >=5.4.0 (5.4.x support will be removed on 14 Sep 2015)

Installation

composer require nella/forms-datetime

Usage

$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');

Manual rendering

{form myForm}
    {label date /}
    {input date}

    {label datetime /}
    {input datetime:date}
    {input datetime:time}
{/form}

License

Date/DateTime control for Nette Framework is licensed under the MIT License - see the LICENSE file for details