{"id":17343476,"url":"https://github.com/firesphere/silverstripe-rangefield","last_synced_at":"2025-04-14T20:11:17.906Z","repository":{"id":30456957,"uuid":"124979025","full_name":"Firesphere/silverstripe-rangefield","owner":"Firesphere","description":"Range field selector for SilverStripe","archived":false,"fork":false,"pushed_at":"2023-10-31T21:59:34.000Z","size":1090,"stargazers_count":4,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-22T23:03:48.021Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Firesphere.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-03-13T02:16:32.000Z","updated_at":"2023-07-24T21:42:10.000Z","dependencies_parsed_at":"2023-01-14T16:59:53.945Z","dependency_job_id":"6e16aff5-4c12-46ce-9ccf-933599addff2","html_url":"https://github.com/Firesphere/silverstripe-rangefield","commit_stats":{"total_commits":53,"total_committers":7,"mean_commits":7.571428571428571,"dds":"0.28301886792452835","last_synced_commit":"e8aefd4ab1cf3c8e5ebd9581c8a3b0cbf556a4a6"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firesphere%2Fsilverstripe-rangefield","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firesphere%2Fsilverstripe-rangefield/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firesphere%2Fsilverstripe-rangefield/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firesphere%2Fsilverstripe-rangefield/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Firesphere","download_url":"https://codeload.github.com/Firesphere/silverstripe-rangefield/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240766095,"owners_count":19854105,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest"],"created_at":"2024-10-15T16:09:30.181Z","updated_at":"2025-02-25T23:33:53.476Z","avatar_url":"https://github.com/Firesphere.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/Firesphere/silverstripe-rangefield.svg?style=svg)](https://circleci.com/gh/Firesphere/silverstripe-rangefield)\n[![codecov](https://codecov.io/gh/Firesphere/silverstripe-rangefield/branch/master/graph/badge.svg)](https://codecov.io/gh/Firesphere/silverstripe-rangefield)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Firesphere/silverstripe-rangefield/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Firesphere/silverstripe-rangefield/?branch=master)\n\n[![Gitstore](https://enjoy.gitstore.app/repositories/badge-Firesphere/silverstripe-rangefield.svg)](https://enjoy.gitstore.app/repositories/Firesphere/silverstripe-rangefield)\n\n# Range field\n\nPlay with ranges in your forms in SilverStripe.\n\n![Demo animation](https://github.com/Firesphere/silverstripe-rangefield/raw/21fe0d3e5d2cfc4cc94183aaea594e39ba49c962/demo.gif)\n\n# Installation\n\n```sh\ncomposer require firesphere/rangefield\n```\n\n# Usage\n\n```php\nuse Firesphere\\RangeField\\RangeField;\nuse SilverStripe\\CMS\\Model\\SiteTree;\n\nclass Page extends SiteTree\n{\n   private static $db = [\n      'RangeValues' =\u003e 'Varchar',\n   ];\n\n   public function getCMSFields()\n   {\n      $fields = parent::getCMSFields();\n\n      $fields-\u003eaddFieldToTab(\n         'Root.Main',\n         RangeField::create('RangeValues', 'Range of values')\n      );\n\n      return $fields;\n   }\n}\n```\n\nMore complex configuration (including range options):\n\n```php\nRangeField::create(\n   $field = 'RangeValues',\n   $title = 'Range of values',\n   $start = 0,\n   $min = 0,\n   $max = 100,\n   $range = [\n      'min' =\u003e 0, // this will override $min\n      '25%' =\u003e 25,\n      '50%' =\u003e 50,\n      '75%' =\u003e 75,\n      'max' =\u003e 100, // this will override $max\n   ],\n   $value = 33\n)\n```\n\nThe field uses [noUiSlider](https://refreshless.com/nouislider), so you can find [more information there](https://github.com/leongersen/noUiSlider).\n\nWhen you change the number of handlers on a field, the values are reset, because it's impossible to determine which of the default values is supposed to be the original value.\n\nSelections are stored as a comma-separated set of values, e.g. `33.00,50.00` You'll need to apply your own logic to use the given values in the frontend.\n\nLimited formatting can be applied to the value via the `setUnit()`, `setDecimalPlace()`, and `setFormat()` methods.\n\n# Options\n\n| Option        | Default   | Method              | Usage                                                   |\n| ------------- | --------- | ------------------- | ------------------------------------------------------- |\n| Snap          | `false`   | `setSnap()`         | Set snapping to points                                  |\n| Data          | `[]`      | `setData()`         | Override the generated data                             |\n| Max           | `0`       | `setMax()`          | Change the maximum value⍟                               |\n| Min           | `100`     | `setMin()`          | Change the minimum value⍟                               |\n| Density       | `5`       | `setDensity()`      | Set the density of the pips                             |\n| Range         | `[]`      | `setRange()`        | Set the range values⍟                                   |\n| Start         | `[0]`     | `setStart()`        | Set the default value⍟                                  |\n| Step          | `null`    | `setStep()`         | Set the step size                                       |\n| Show Pips     | `true`    | `setShowPips()`     | Show or hide the pips                                   |\n| Snap          | `false`   | `setSnap()`         | Snap to the range-set values instead of fluid           |\n| Unit          | `''`      | `setUnit()`         | Append a unit to the output value                       |\n| Decimal Place | `2`       | `setDecimalPlace()` | Format the number of decimal places in the output value |\n| Format        | `''`, `2` | `setFormat()`       | A shortcut for setting both units and decimal places    |\n\n⍟ These items can be set in the construct/create method\n\n# Using the field in the frontend (= public site)\nIf you need to use this field not only in the admin section, but in the frontend, you need to define a couple of CSS and JavaScript requirements in your `PageController` class:\n\napp/src/PageController.php:\n```php\nclass PageController extends ContentController\n{\n\t\n\tprotected function init()\n\t{\n\t\tparent::init();\n\t\t// You can include any CSS or JS required by your project here.\n\t\t// See: https://docs.silverstripe.org/en/developer_guides/templates/requirements/\n\t\t\n\t\t// RangeField\n\t\tRequirements::css('firesphere/rangefield:client/dist/main.css');\n\t\tRequirements::javascript('firesphere/rangefield:client/dist/main.js');\n\t\t\n\t}\n}      \n```\n\nIf you are only using this module in the admin section, you don't need to do this because those requirements are automatically defined for the admin section.\n\n# Known issues\n\n- Multiple start values seem not to work properly\n- Slider starts at minimum rather than current value after publish\n\n# License\n\nThis module is published under BSD 3-clause license, although these are not in the actual classes, the license does apply:\n\nhttp://www.opensource.org/licenses/BSD-3-Clause\n\n```\nCopyright (c) 2012-NOW(), Simon \"Firesphere\" Erkelens\n\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\n- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n```\n\n# Did you read this entire readme? You rock!\n\nPictured below is a cow, just for you.\n\n```\n               /( ,,,,, )\\\n              _\\,;;;;;;;,/_\n           .-\"; ;;;;;;;;; ;\"-.\n           '.__/`_ / \\ _`\\__.'\n              | (')| |(') |\n              | .--' '--. |\n              |/ o     o \\|\n              |           |\n             / \\ _..=.._ / \\\n            /:. '._____.'   \\\n           ;::'    / \\      .;\n           |     _|_ _|_   ::|\n         .-|     '==o=='    '|-.\n        /  |  . /       \\    |  \\\n        |  | ::|         |   | .|\n        |  (  ')         (.  )::|\n        |: |   |;  U U  ;|:: | `|\n        |' |   | \\ U U / |'  |  |\n        ##V|   |_/`\"\"\"`\\_|   |V##\n           ##V##         ##V##\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffiresphere%2Fsilverstripe-rangefield","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffiresphere%2Fsilverstripe-rangefield","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffiresphere%2Fsilverstripe-rangefield/lists"}