Forums Forums Search & Filter Pro Prefix values in options

Tagged: 

Viewing 7 posts - 1 through 7 (of 7 total)
  • Anonymous
    #274397

    Could i prefix values in options to be selected in the filter?

    Trevor
    #274490

    You could do it using this filter:

    https://searchandfilter.com/documentation/action-filter-reference/#filter-input-object

    You need to loop through and add to the label. I am not sure if this affects any label like ‘All Categories’. If it does, you can exclude it from the loop because it is always the first one in the array.

    Anonymous
    #274552

    Ok! so how could I make a checked option?

    add_filter( ‘sf_input_object_pre’, ‘filter_function_name’, 10, 2 );
    function filter_function_name( $input_object, $sfid )
    {
    if ( $input_object[‘name’]==’_sfm_aff_price_type’ ) {
    //udpate this field before rendering
    }

    return $input_object;
    }

    It returns this object:
    input_object:Array
    (
    [name] => _sfm_aff_price_type
    [defaults] => Array
    (
    [0] =>
    )

    [options] => Array
    (
    [0] => stdClass Object
    (
    [label] => Mensual
    [count] => -1
    [attributes] => Array
    (
    [class] => sf-level-0
    )

    [value] => month
    )

    [1] => stdClass Object
    (
    [label] => Trimestral
    [count] => -1
    [attributes] => Array
    (
    [class] => sf-level-0
    )

    [value] => quaterly
    )

    )

    [attributes] => Array
    (
    [data-operator] => and
    [class] =>
    )

    [accessibility_label] =>
    [type] => checkbox
    [input_class] => sf-input-checkbox
    )

    Which value do I have to change to make month checked in radio?

    Anonymous
    #274736

    Could you help me?

    Trevor
    #274948

    Sorry, I am working my way through a backlog. I had thought you meant to prefix the label with a text string, but it appears you want to do something different?

    Could you explain in detail what type of field you are starting with, and what you are trying to do to it?

    Anonymous
    #275676

    Yep. I’d like to have a filter already defined by default. It’s a checkbox to select options.

    Trevor
    #275705

    Ah. I am sorry, that isn’t possible. We hope to be able to introduce the option to set a default (pre-selected) value (in the absence of a user selection) during the V3 release cycle (V3.0 will be a few months yet) and, similarly, checkboxes in a dropdown select field.

Viewing 7 posts - 1 through 7 (of 7 total)