Forums › Forums › Search & Filter Pro › Customize Value Postfix
- This topic has 23 replies, 3 voices, and was last updated 5 years, 5 months ago by Anonymous.
-
Anonymous(Private) June 23, 2019 at 2:57 pm #214652
Hi,
I have a drop-down range setup for one of my ACF fields, using the Value Postifx option creates:
5miles – 15miles
But I want it to display as:
5 – 15miles
I’ve looked at using CSS pseudo techniques but I don’t believe it works with select options because they are generated by the OS/Browser.
Any help appreciated.
Trevor(Private) June 24, 2019 at 12:47 pm #214731Thanks for that. You have two choices. If you are unlikely to changing the options very often, you can change the population of the field in the form from Automatically to Manual. That way you can edit the labels, and also the order.
If that will not work as the options may change a lot, then you would have to sue this filter to programmatically change them:
https://searchandfilter.com/documentation/action-filter-reference/#filter-input-object
Anonymous(Private) June 24, 2019 at 1:21 pm #214739Thank you, I’m using the Number Range option for the distance drop-down and that doesn’t have a manual entry option, if I switch to Choice then it does have manual entry but then it isn’t a range. So I assume the only way for this to work would be using the filter?.
I’ve looked at the full example here:https://gist.github.com/rmorse/7b59b45a14b1ca179868
I understand some PHP but this a little advanced for me, would changing the following postfix line work?:
//add/override prefix & postfix to the field
$input_object[‘prefix’] = “Prefix”;
$input_object[‘postfix’] = “miles”;Trevor(Private) June 25, 2019 at 5:16 pm #214907I would imagine the PHP would be something like:
function add_miles_to_filter_labels($input_object, $sfid) { if(($input_object['name']!='_sfm_colours') { return $input_object; } foreach($input_object['options'] as $option) } $option->label .= " miles"; } return $input_object; } add_filter('sf_input_object_pre', 'add_miles_to_filter_labels', 10, 2);
where you change $sfid to the actual ID of the form AND
where you change the string/name_sfm_colours
to whatever thedata_sf_field_name
actually is, for example, see here:Anonymous(Private) June 25, 2019 at 6:18 pm #214925ok this is what I have so far:
function add_miles_to_filter_labels($input_object, $2116) { if(($input_object['name']!='_sfm_distance[]') { return $input_object; } foreach($input_object['options'] as $option) } $option->label .= " miles"; } return $input_object; } add_filter('sf_input_object_pre', 'add_miles_to_filter_labels', 10, 2);
I’ve tried with and without the $ sign in front of the id, but I still get a parse error on the site.
-
AuthorPosts