Search Results for 'sf_input_object_pre'

Forums › Forums › Search › Search Results for 'sf_input_object_pre'

Viewing 10 results – 111 through 120 (of 146 total)
  • Author
    Search Results
  • #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?

    #80200

    Trevor
    Participant

    Are you saying that, on the S&F Pro form settings page, on the Posts tab, you tried it with the Primary sort as date and secondary sort as name? I would have thought that should have worked. as you say, there should be no need for the secondary sort, as the date would be sufficient.

    My initial though would be that you could code around this using one of our filters. See here in the documentation.

    If you use the filter sf_input_object_pre you get access to the options as an array, so you can order this array however you want, so you can use this to sort the array with php. But you would need to code this.

    #79998

    Trevor
    Participant

    See here in the documentation.

    If you use the filter sf_input_object_pre you get access to the options as an array, so you can order this array however you want.

    You Do have access to the count variable, so you can use this to sort the array with php. But you would need to code this.

    #76187

    In reply to: Default option on load


    Anonymous
    Inactive

    Hey Trevor,

    Thank you.

    After numerous other options I tried the below but not sure I’m in the right zone (the custom class is added to the field so it’s partly working).

    I just want to pull one of the options from that dropdown as the default on that page (selected option on page load).

    Any pointers?

    Thank you!

    <?php function filter_input_object($input_object, $sfid) {
    if ($input_object[‘name’] == ‘_sft_testcat’) {
    $input_object[‘defaults’] = array(“Test”);
    $input_object[‘attributes’][‘class’] = ‘mynew_class’;
    }

    return $input_object;

    }
    add_filter(‘sf_input_object_pre’, ‘filter_input_object’, 10, 2); ?>

    #73812

    Ross
    Keymaster

    Hey Ash

    The best way to get the current value is to use our active query class:

    https://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/

    Because you want the actual value it might be best to use the array method and pull your value from there.

    Alternatively, when using the sf_input_object_pre filter, the defaults should already be set to the current value from the URL, as its this default argument that is set by S&F and will be used to set the selected state.

    Doing a var_dump of $input_object['defaults'] should show the currently active value, if you access it at the top of your function before you’ve made any modifications (note: this will always be an array even for single selection type fields)

    Hope that makes sense?

Viewing 10 results – 111 through 120 (of 146 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.