Forums Forums Search Search Results for 'sf_input_object_pre'

Viewing 10 results - 101 through 110 (of 137 total)
  • Author
    Search Results
  • #141127

    Trevor
    Participant

    Are these meta keys being searched with a Range field, because that would cause the problem. At this time you can sort of work around it (by using the Edit Query Argument filter to remove the unwanted range parameters). There will be snippets other users have posted on how they did this if you search for:

    sf_input_object_pre range

    #126699

    In reply to: Filter default values


    Anonymous
    Inactive

    Thanks for the link.

    I fixed it the following way:

    function filter_function_name($input_object, $sfid) {
      if($input_object['name']=='xxx') {
        $input_object['defaults'] = array("yyy");
      }
      return $input_object;
    }
    add_filter('sf_input_object_pre', 'filter_function_name', 10, 2);
    #114750

    Anonymous
    Inactive

    Hi,

    I need to apply a category filter onload rather than showing all categories. I’ve used the below code to set the default to ‘news’ and removed the all option. But it still loads all the posts rather than just the news post on load.

    add_filter(‘sf_input_object_pre’, function ($input_object, $sfid)
    {
    if(($input_object[‘name’]!=’_sft_category’))
    {
    return $input_object;
    }
    $input_object[‘defaults’] = array(“news”);
    array_shift($input_object[‘options’]);
    return $input_object;
    } , 10, 2);

    #105123

    Ross
    Keymaster

    Hi Javier

    You can do this with the current version..

    Take a look at the docs here:

    https://www.designsandcode.com/documentation/search-filter-pro/action-filter-reference/#Filter_Input_Object

    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

    #92674

    In reply to: Optional Class Name


    Trevor
    Participant

    At this time, it is possible to add CSS identifiers (IDs and Classes) only to the term elements, and not the containing form elements. It is a feature we plan to add to the next major update (V3), which we are currently working on.

    To modify the input objects you would have to write your own code using the sf_input_object_pre filter.

    Most objects in the form do have their own CSS class that you can target with Custom CSS. You can use the browser inspector to find these.

    #87711

    Trevor
    Participant

    As to the first part of the question above, try changing the type of form field to Checkbox or radio and see if that looks closer in terms of the HTML structure. For me it does.

    As to the second part, I understand. In your UL example, if that field had a filter selected, it would be the li that has the extra class to show it is selected, but CSS allows you to target the parent of an element that has a given class (in this case it would be the class sf-option-active). You can hide the checkbox with custom CSS as well.

    Our sf_input_object_pre filter allows you to target these inner elements also.

    #85783

    Anonymous
    Inactive

    I tried using CSS, unfortunately Macs/ Safari refuse to honor display:none;

    Regarding the code
    // add indent to dropdown

    function filter_function_name($input_object, $sfid87) //I cant change it to just 87 as its expecting a variable
    {
    if($input_object[‘name’]==’_my_field_name’) // this should be the class name?
    {
    //udpate this field before rendering
    $input_object = ”  “. $input_object;
    }

    return $input_object;
    }
    add_filter(‘sf_input_object_pre’, ‘filter_function_name’, 10, 2); // what is 10,2 is that something that I should be changing?

    Sorry to be such a bother.

    #85602

    Trevor
    Participant

    You can add classes for form elements using our Filter Input Object sf_input_object_pre filter.

    #83471

    Anonymous
    Inactive

    Thank you.

    My php isn’t that great, would it would be something like;

    function filter_function_name($input_object, $sfid=87)
    {
    if($input_object[‘name’]==’sf-level-1′)
    {
    //udpate this field before rendering
    $input_object[‘attributes’][‘style’] = ‘margin-left:50px;’;
    }

    return $input_object;
    }
    add_filter(‘sf_input_object_pre’, ‘filter_function_name’, 10, 2);

    #82378

    Anonymous
    Inactive

    All of a sudden the search forms have stopped sorting. The page is here: https://intrepidexposures.com/photo-tours/

    Tweaks to code as per previous threads here:

    // Search Filter
    function filter_input_object($input_object, $sfid) {
    	
    if(($input_object['name'] == '_sfm_workshop_location') || ($input_object['name'] == '_sfm_tour_style') || ($input_object['name'] == '_sfm_tour_leader')) {
    
    		
    		$new_options = array(); //the options added to this will replace all existing optoins in the field
    		
    		foreach($input_object['options'] as $option) {
    			
    			if ($option->value !== "")
    			{
    				//check to see if the option has a parent
    				$parent_id = wp_get_post_parent_id($option->value);
    				if(!$parent_id)
    				{
    					//then this option does not have a parent, so it must be a parent itself, add it to the new array
    					$option->label = get_the_title($option->value);
    					array_push($new_options, $option);
    				}
    			}
    		}
    		
    		//now we have an array with only parent options in, so simply replace the one in the input object
    		$input_object['options'] = $new_options;
    		
    	}
    	
    	return $input_object;
    }
    add_filter('sf_input_object_pre', 'filter_input_object', 10, 2);

    Any ideas?

Viewing 10 results - 101 through 110 (of 137 total)