landrisek/nette-range

Nette 框架 >2.0 的范围表单控件。

安装: 40

依赖项: 0

建议者: 0

安全性: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

语言:JavaScript

1.0 2017-05-05 08:53 UTC

This package is not auto-updated.

Last update: 2024-09-15 00:29:57 UTC


README

Nette 表单范围扩展

演示

安装

  1. 如果您还没有安装,请运行 composer
  2. 运行 composer require landrisek/nette-range:1.*
  3. 从 nette-range/assets 复制文件到您的 www/assets,并在模板中包含它们,或者按照可选设置进行操作

必需设置

编辑您的 config.neon

扩展:range: Range\RangeExtension

添加到模板

<a href="#" onclick="submitRange();">{input yourSubmitButton}</a>

在 MyForm::attached 中添加:$this->addRange('myRangeId', 'My range label')->setDefaultValue('min'=>$minimalValue,'max'=>$maximalValue,'from'=>$fromValue,'to'=>$toValue);

在 MyForm::render 中添加:$this->templates->ranges = ['myRangeId','myOtherRangeId'];

在 formSucced 方法中,您将得到数组

public function formSucceed($form) {
    $values = $form->getValues();
    $from = $values['myRangeId']['from'];
    $to = $values['myRangeId']['to'];
}

可选设置

编辑您的 config.neon

服务

  • Range\IRangeFactory

添加到您的表单/组件

/** @var IRangeFactory */
private $rangeFactory;
public function __construct(Range\IRangeFactory $rangeFactory) {
    $this->rangeFactory = $rangeFactory;
}
protected function createComponentRange() {
    return $this->rangeFactory->create();
}

添加到您的表单/组件的模板

{control range:head}
{control $myForm}
{control range:footer}