Forums › Forums › Search & Filter Pro › Range Select: Add value at the beginning (text)
Tagged: V3 Ideas
- This topic has 12 replies, 3 voices, and was last updated 7 years, 7 months ago by Trevor.
-
Ross Moderator(Private) April 27, 2017 at 12:58 am #105123
Hi Javier
You can do this with the current version..
Take a look at the docs here:
Nearly any value in any input object can be changed if you dig deep enough into the
$input_object
there are all kinds of things that can be changed.Tested locally, and updated to match your field name
_sfm_precio
, this should do the trick:function filter_range_dropdown($input_object, $sfid) { if($input_object['name']=='_sfm_precio') { //udpate this field before rendering //if we want to filter the options generated, we need to make sure the options variable actually exists before proceeding (its only available to certain field types) if(!isset($input_object['options'])) { return $input_object; } //now loop through the options in the field foreach($input_object['options'] as $option) { //update every label, and prefix and suffix with $ $option->label = "$ ".$option->label." $"; } } //always return the input object, even if we made no changes return $input_object; } add_filter('sf_input_object_pre', 'filter_range_dropdown', 10, 2);
Hope that helps
Anonymous(Private) April 27, 2017 at 1:06 pm #105196That is absolutely fantastic!
I made a little change in the line that ads the currency symbol to use with euro only at the beginning.One las question: With this code in mind … is there a way to add an “initial option” with text: “Price from” and “Price to” ??
I know I asked before that but just want to be sure.
Thanks! -
AuthorPosts