surda / datetime-period
Datetime period control for Nette Framework
v1.0.0
2019-10-16 13:27 UTC
Requires
- php: >=7.1
- nesbot/carbon: ^2.0
- nette/di: ^3.0
- surda/themeable-controls: ^1.0
Requires (Dev)
- nette/tester: ^2.0
- ninjify/nunjuck: ^0.3
- phpstan/phpstan: ^0.11
- phpstan/phpstan-deprecation-rules: ^0.11
- phpstan/phpstan-nette: ^0.11
- phpstan/phpstan-strict-rules: ^0.11
This package is auto-updated.
Last update: 2024-11-17 00:39:43 UTC
README
Installation
The recommended way to is via Composer:
composer require surda/datetime-period
After that you have to register extension in config.neon:
extensions: monthPeriod: Surda\DateTimePeriod\DI\MonthPeriodExtension
Configuration
Default
monthPeriod: templates: default: bootstrap4.default.latte useAjax: FALSE
Usage
Presenter
use Surda\DateTimePeriod\MonthPeriod\MonthPeriod; use Surda\DateTimePeriod\MonthPeriod\MonthPeriodControl; use Surda\DateTimePeriod\MonthPeriod\TMonthPeriod; class ProductPresenter extends Nette\Application\UI\Presenter { use TMonthPeriod; public function actionDefault(): void { /** @var MonthPeriodControl $mp */ $mp = $this->getComponent('mp'); /** @var MonthPeriod $monthPeriod */ $monthPeriod = $mp->getMonthPeriod(); } }
Template
{control mp} or {control mp template}
Custom options
class ProductPresenter extends Nette\Application\UI\Presenter { /** * @return MonthPeriodControl */ protected function createComponentMp(): MonthPeriodControl { $control = $this->monthPeriodControlFactory->create(); $control->onChange[] = function (MonthPeriodControl $control, MonthPeriod $monthPeriod): void { $this->redirect('this'); }; return $control; } }