Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
tr33m4n CreditAttribution: tr33m4n commentedTurns out it was an issue with SliderField
Comment #2
GuyPaddock CreditAttribution: GuyPaddock commented@tr33m4n: What was the issue? I'm trying this now...
Comment #3
tr33m4n CreditAttribution: tr33m4n commentedI can't remember unfortunately, it was some time ago and I think the project got cancelled, sorry about that
Comment #4
GuyPaddock CreditAttribution: GuyPaddock commentedOk. 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.