landrisek / nette-range
Range form control for Nette framework >2.0.
Installs: 42
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Language:JavaScript
Requires
- php: >= 5.6.0
- nette/nette: >= 2.0
This package is not auto-updated.
Last update: 2025-02-02 02:46:28 UTC
README
Range extension for nette forms
Demo
- Composer package: https://packagist.org/packages/landrisek/nette-range
Installation
- Install composer if you don't have it yet
- run
composer require landrisek/nette-range:1.*
- Copy files from nette-range/assets to your www/assets and include them into your template or follow Optional settings
Required settings
Edit your config.neon
extensions: range: Range\RangeExtension
Add to template:
<a href="#" onclick="submitRange();">{input yourSubmitButton}</a>
Add in MyForm::attached: $this->addRange('myRangeId', 'My range label') ->setDefaultValue('min'=>$minimalValue,'max'=>$maximalValue,'from'=>$fromValue,'to'=>$toValue);
Add in MyForm::render: $this->templates->ranges = ['myRangeId','myOtherRangeId'];
In formSucced method you will get array:
public function formSucceed($form) {
$values = $form->getValues();
$from = $values['myRangeId']['from'];
$to = $values['myRangeId']['to'];
}
Optional settings
Edit your config.neon:
services:
- Range\IRangeFactory
Add to your form / component:
/** @var IRangeFactory */
private $rangeFactory;
public function __construct(Range\IRangeFactory $rangeFactory) {
$this->rangeFactory = $rangeFactory;
}
protected function createComponentRange() {
return $this->rangeFactory->create();
}
Add to template of your form / component:
{control range:head}
{control $myForm}
{control range:footer}