Skip Navigation

[Resolved] Radio not checked in search form with default

This thread is resolved. Here is a description of the problem and solution.

Problem:
Radio not checked in search form with default value when added as view's filter

Solution:
You should add custom JS to your view's JS box to check the default radio button.

You can find the proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/radio-not-checked-in-search-form-with-default/#post-1166240

Relevant Documentation:

This support ticket is created 5 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 6 replies, has 2 voices.

Last updated by Minesh 5 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#1165744

I am trying to: build a cpt search form, including the Blend custom field.

Link to a page where the issue can be seen: hidden link

Please use user/pw as shown at URL to admin.

I expected to see: something like hidden link

Instead, I got: Blend field not checked with default (Όχι)

#1166200

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - I try to use the authorization access details you shared with us but unfortunately its not working.

Could you please authorization access once again and send it to me.

I have set the next reply to private which means only you and I have access to it.

#1166203
#1166240

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - I've added the following JS code to your view's JS box:

 var default_value = $.getQuery('wpv-wpcf-blend');
  
   if(default_value == false){
     jQuery("input[name='wpv-wpcf-blend']:first").attr('checked', true);
   }

(function($){
    $.getQuery = function( query ) {
        query = query.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
        var expr = "[\\?&]"+query+"=([^&#]*)";
        var regex = new RegExp( expr );
        var results = regex.exec( window.location.href );
        if( results !== null ) {
            return results[1];
            return decodeURIComponent(results[1].replace(/\+/g, " "));
        } else {
            return false;
        }
    };
})(jQuery);

I can see now default radio button is selected.

#1166253

Wow, all this code for a default radio to be checked...?
It works though, thanks a lot Minesh.
I need to know, is this a bug?

Best regards,
Kostas

#1166259

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes, it seems to be. I will report it as per the process. But for now, you can use the workaround I shared.

#1166265

My issue is resolved now. Thank you Minesh!

Best regards,
Kostas

#1167497

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - I confirm that the default option setting does not respected when you add the same field as filter is not a bug.

It will be treated as a brand new feature request, please feel free to submit the feature request using the following link:
=> https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.