Forums › Forums › Search & Filter Pro › Prefix values in options
Tagged: V3
- This topic has 6 replies, 2 voices, and was last updated 3 years, 8 months ago by Trevor.
-
Trevor(Private) January 29, 2021 at 4:57 am #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(Private) January 29, 2021 at 1:22 pm #274552Ok! 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?
Trevor(Private) February 2, 2021 at 10:19 am #274948Sorry, 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?
Trevor(Private) February 15, 2021 at 10:12 am #275705Ah. 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.
-
AuthorPosts