Forums › Forums › Search & Filter Pro › Customize Value Postfix
- This topic has 23 replies, 3 voices, and was last updated 6 years, 2 months ago by
Anonymous.
-
Trevor(Private) June 24, 2019 at 12:47 pm #214731
Thanks 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.
Trevor(Private) June 25, 2019 at 6:36 pm #214927It shouldn’t have the dollar symbol, no.
I can see an error also, so try this:
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);
-
AuthorPosts