Skip Navigation

[Gelöst] Radio not checked in search form with default

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

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 vor 5 Jahren, 11 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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)

Dieses Thema enthält 6 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Minesh vor 5 Jahren, 11 Monaten.

Assistiert von: Minesh.

Author
Artikel
#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: versteckter Link

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

I expected to see: something like versteckter Link

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

#1166200

Minesh
Supporter

Sprachen: Englisch (English )

Zeitzone: 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

Sprachen: Englisch (English )

Zeitzone: 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

Sprachen: Englisch (English )

Zeitzone: 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

Sprachen: Englisch (English )

Zeitzone: 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/