horst Posted July 2, 2014 Share Posted July 2, 2014 Have try (tried?) some more and found that the defaultValue do work with a little change inthe code: https://github.com/somatonic/RangeSlider/pull/1 But the main question is when using it in a modules configpage like in the above post, how can I get the result stored into the config-data? Is this possible? Link to comment Share on other sites More sharing options...
Soma Posted July 3, 2014 Author Share Posted July 3, 2014 Thanks Horst for bringing this up. I tried some things with using this fieldtype as config field. But it wasn't saving correctly due to it's value type of object. I made some major changes to this fieldtype. In short, the value now is handled as an array value and not as RangeSlider object anymore. See upgrade and changelog here: https://github.com/somatonic/FieldtypeRangeSlider#upgrade-notes (BTW Also renamed the module repo to FieldtypeRangeSlider) These changes now also allow for using the Inputfield as a config field in modules. Previously it wasn't possible, as the value saved wasn't treated as array. Simplest solution seemed to make the Inputfield implement InputfieldHasArrayValue. Regarding the defaultValue. This was only set and used in the Fieldtype and not Inputfield! So the defaultValue will be set to the field value. Inputfield then just deals with the value min and max. Since when using this module as a config field only, there's no fieldtype involved at all. Here just an example how to handle it as a config field. protected static $defaults = array( 'myrange' => array('min' => 10, 'max' => 90), 'myslider' => array('min' => 10) ); public static function getModuleConfigInputfields(array $data){ $data = array_merge(self::$defaults, $data); $fieldset = new InputfieldWrapper(); $modules = wire('modules'); // range with two values $field = $modules->InputfieldRangeSlider; $field->attr('name', 'myrange'); $field->attr('value', array( 'min' => $data['myrange']['min'], 'max' => $data['myrange']['max']) ); $field->isrange = true; $field->width = 90; $field->minValue = 1; // min value config $field->maxValue = 100; // max value config $field->step = 1; $field->label = 'Slider 2 range values'; $fieldset->add($field); // no range, only single value $field = $modules->InputfieldRangeSlider; $field->attr('name', 'myslider'); $field->attr('value', array( 'min' => $data['myslider']['min']) ); $field->isrange = false; $field->width = 90; $field->minValue = 1; $field->maxValue = 100; $field->step = 1; $field->label = 'Slider 1 value'; $fieldset->add($field); return $fieldset; } 4 Link to comment Share on other sites More sharing options...
horst Posted July 3, 2014 Share Posted July 3, 2014 @Soma: many thanks for these mods. Works like a charm in configpages now! Link to comment Share on other sites More sharing options...
Juergen Posted October 12, 2016 Share Posted October 12, 2016 Hello @Soma, only to mention: your slider field doesnt work in repeater items (tested with PW 3.0.35) but outside a repeater it works well!! Best regards Link to comment Share on other sites More sharing options...
spoetnik Posted May 27, 2019 Share Posted May 27, 2019 What would be needed to get this module to work with Processwire 3? I get the error 'FieldtypeRangeSlider: Default value should be in format [int,int]. (1,100) if range is checked' 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