atk14 / range-field
RangeField is a form field for entering numeric range from and to in ATK14 applications
Installs: 11 216
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: >=5.3.0
Requires (Dev)
- atk14/core: dev-master
- atk14/forms: dev-master
- atk14/tester: *
README
RangeField is a field for entering two numeric values within specified minimum and maximum.
In eshops, this is an useful field, for example, for setting the price range for product selection.
Usage
<?php
// file: app/forms/products/index_form.php
class IndexForm extends ApplicatonForm {
function set_up(){
$this->add_field("search", new CharField([
"label" => "Search",
"required" => false,
]));
$this->add_field("price", new RangeField([
"label" => "Price range",
"min_value" => 1,
"max_value" => 100000,
"required" => false,
]));
}
}
<?php
// file: app/controllers/products_controller.php
class ProductsController extends ApplicationController {
function index(){
$d = $this->form->validate($this->params);
$min = $d["price"]["min"];
$max = $d["price"]["max"];
// ..
}
}
Installation
Just use the Composer:
cd path/to/your/atk14/project/
composer require atk14/range-field
Optionally you can symlink RangeField files into your project:
ln -s ../../vendor/atk14/range-field/src/app/fields/range_field.php app/fields/range_field.php
ln -s ../../vendor/atk14/range-field/src/app/widgets/range_input.php app/widgets/range_input.php
Testing
composer update --dev
cd test
../vendor/bin/run_unit_tests
License
RangeField is free software distributed under the terms of the MIT license