Hello there,

I wanted to use a jquery slider field for the distance in the exposed proximity form, so downloaded the module SliderField. I have overridden the exposed form elements using the following:

function mymodule_proximity_element_process($element, &$form_state, $form) {
    if ($form_state['view']->name == 'events' && $form_state['view']->current_display == 'page'){
        $element['distance']['#type'] = 'slider';
        $element['distance']['#default_value'] = 10;
        $element['distance']['#range'] = 'max';
        $element['distance']['#min'] = 1;
        $element['distance']['#max'] = 100;
        $element['distance']['#step'] = 1;
        $element['distance']['#display_inputs'] = FALSE;
        $element['distance']['#display_values'] = TRUE;
        $element['distance']['#display_values_format'] = '%{value}% miles';
        $element['distance']['#slider_length'] = '100%';
        $element['unit']['#default_value'] = GEOFIELD_MILES;
        $element['unit']['#access'] = FALSE;
        $element['origin']['#attributes']['placeholder'] = t('Postcode, city, etc');
        $element['origin']['#prefix'] = NULL;
        return $element;
    }
 return $element;
}

This displays the slider instead of the distance text field, however when using the slider to select a distance value the following error occurs:

Distance must be a positive integer.

Just wondering whether anyone knows what I might be doing wrong?

Thanks

Comments

tr33m4n’s picture

Status: Active » Closed (works as designed)

Turns out it was an issue with SliderField

GuyPaddock’s picture

@tr33m4n: What was the issue? I'm trying this now...

tr33m4n’s picture

I can't remember unfortunately, it was some time ago and I think the project got cancelled, sorry about that

GuyPaddock’s picture

Ok. I ended up needing to just add a #process callback to the element so that I could modify it's #parents array to put the values where they needed to be in the form state.