landrisek/nette-range

Range form control for Nette framework >2.0.

Installs: 40

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Language:JavaScript

1.0 2017-05-05 08:53 UTC

This package is not auto-updated.

Last update: 2024-05-11 22:55:55 UTC


README

Range extension for nette forms

Demo

Installation

  1. Install composer if you don't have it yet
  2. run composer require landrisek/nette-range:1.*
  3. 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}