Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/vladahejda/datetimecontrol

Nette DateTime Form Control
https://github.com/vladahejda/datetimecontrol

Last synced: about 1 month ago
JSON representation

Nette DateTime Form Control

Awesome Lists containing this project

README

        

Nette DateTime Form Control
===========================

**including week number choice**

Installation
------------

- link jQuery into your page
```html

```

- link jQuery UI:
```html

```

- Download and link [jQuery UI Datepicker](http://trentrichardson.com/examples/timepicker/)
```html

```

- Download [DateTimeControl.php](https://raw.githubusercontent.com/VladaHejda/DateTimeControl/master/src/DateTimeControl.php), let it load by autoloading

- Download [datetimepicker.js](https://raw.githubusercontent.com/VladaHejda/DateTimeControl/master/src/datetimepicker.js) and link it
```html

```

- If you want to localize the calendar, download or create similar localization file as [here](localization).

- add method into your app, e.g. in `BasePresenter::startup()`:
```php
use Nette\Forms;
use Nais\Components\DateTimeControl;

Forms\Container::extensionMethod('addDateTime', function (Forms\Container $form, $name, $label = NULL, $cols = NULL, $invalidMessage = NULL) {
return $form[$name] = new DateTimeControl($label, $cols, $invalidMessage);
});
```

- use it:
```php
$form->addDateTime('from')
->setDefaultValue(new \Nette\DateTime('- 1 day'))
->setTimeFormat(NULL);
```

- and customize:
```php
use Nais\Components\DateTimeControl;

DateTimeControl::$months = array('leden', 'únor', 'březen', 'duben', 'květen', 'červen', 'červenec', 'srpen',
'září', 'říjen', 'listopad', 'prosinec');
DateTimeControl::$monthsShort = array('led', 'úno', 'bře', 'dub', 'kvě', 'čer', 'čvc', 'srp', 'zář', 'říj',
'lis', 'pro');
DateTimeControl::$days = array('neděle', 'pondělí', 'úterý', 'středa', 'čtvrtek', 'pátek', 'sobota');
DateTimeControl::$daysShort = array('ne', 'po', 'út', 'st', 'čt', 'pá', 'so');
DateTimeControl::$defaultDateFormat = 'dd. mm. yy';
DateTimeControl::$defaultTimeFormat = '(HH:mm)';
```