eelkenet Posted October 16, 2019 Share Posted October 16, 2019 Hi! I've created a small Inputfield module called InputfieldFloatRange which allows you to use an HTML5 <input type="range" ../> slider as an InputField. I needed something like this for a project where the client needs to be able to tweak this value more based on 'a feeling' than just entering a boring old number. Maybe more people can use this so I'm hereby releasing it into the wild. EDIT: You can now install it directly from the Modules directory: http://modules.processwire.com/modules/inputfield-float-range/ What is it? The missing range slider Inputfield for Processwire. What does it do? This module extends InputfieldFloat and allows you to use HTML5 range sliders for number fields in your templates. It includes a visible and editable value field, to override/tweak the value if required. Features Min/max values Precision (number of decimals) Optional step value (Read more) Optional manual override of the selected value (will still adhere to the rules above) Configurable rounding of manually entered values (floor, round, ceil, disable) Usage Clone / zip repo Install FieldtypeFloatRange, this automatically installs the Inputfield Create new field of type `Float (range)` or convert an existing `Float`, `Integer` or `Text` field. To render the field's value simply echo `$page->field` Demo A field with Min=0, Max=1, Step=0.2, Precision=2 Field with settings Min=0, Max=200, Step=0.25, Precision=2 Todo Make the display-field's size configurable (will use the Input Size field setting) Hopefully become redundant Changelog 008 (current version) - Add composer.json and submit to Packagist, making the module installable via composer 007 - Add defaultValue field (as requested by @charger) - Fix a silly mistake where a negative rounding (-1) resulted in removing all decimals instead 006 - Fix bug where InputfieldFloat negative precision prevented the displayed value to be updated properly - Revert installs & requires, so direct installs from Modules Directory (should) work 005 - Fix bug where the Inputfield would not work properly within repeaters / repeater matrices 004 - Make rounding of manually entered values configurable (floor, round, ceil or disable) - Fix small JS bug where the value-display field was not displayed - Update README 003 - Code cleanup, add some ModuleInfo data & LICENSE - Submit to PW Modules directory (http://modules.processwire.com/modules/inputfield-float-range/) 002 - Fix issue where setting the step value to an empty value created problem with validation - Make the display-field optional 001 - Initial release Thanks! 9 1 Link to comment Share on other sites More sharing options...
bernhard Posted October 16, 2019 Share Posted October 16, 2019 Hi @eelkenet, thx for sharing ? Did https://modules.processwire.com/modules/range-slider/ not work for you or did you need other features? Would be nice to see the differences between your modules. We also have this one: 1 Link to comment Share on other sites More sharing options...
eelkenet Posted October 16, 2019 Author Share Posted October 16, 2019 48 minutes ago, bernhard said: Hi @eelkenet, thx for sharing ? Did https://modules.processwire.com/modules/range-slider/ not work for you or did you need other features? Would be nice to see the differences between your modules. To be honest I didn't check out that module in a long time, and had even forgotten it existed.. ? But the major differences would be FieldtypeRangeSlider is a full-fledged module with its own API, depends on jQueryUI, and.. has not been updated in 5 years. The one I created is much simpler and light-weight: it's really just a basic HTML5 <input type='range'> with some styling, feedback and validation. As such, it is just another way to use the regular Float/Integer inputfields. 5 1 Link to comment Share on other sites More sharing options...
Macrura Posted October 16, 2019 Share Posted October 16, 2019 https://modules.processwire.com/modules/jquery-ion-range-slider/ this one also works for more complex range needs Link to comment Share on other sites More sharing options...
eelkenet Posted October 21, 2019 Author Share Posted October 21, 2019 (edited) The module has been updated to 004 005. Besides a small JS bugfix, this update makes the rounding of manually entered values configurable (floor, round, ceil or disable completely). Edit: As of version 005 it also works within repeaters / repeater matrix, thanks to @Robin S' help. Edited October 22, 2019 by eelkenet Updated to 005 1 Link to comment Share on other sites More sharing options...
charger Posted May 17, 2023 Share Posted May 17, 2023 Would be cool if the field allows for a default value (next to min and max), so e.g. when min is 0 and max is 1, it currently defaults to 0.5, but I would sometimes prefer the default to be 0. @eelkenet would this be complicated to implement? Link to comment Share on other sites More sharing options...
eelkenet Posted May 25, 2023 Author Share Posted May 25, 2023 Hi @charger, Good idea! I've pushed a new version with a defaultValue field, where you should be able to accomplish what you need. Please let me know if you bump into any issues? 1 Link to comment Share on other sites More sharing options...
charger Posted June 9, 2023 Share Posted June 9, 2023 @eelkenet perfect, works great. Thanks a lot! 1 Link to comment Share on other sites More sharing options...
2hoch11 Posted June 26 Share Posted June 26 I tried to use it as as a custom field in an ImageField but no luck… ? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now