Skip Navigation

[Resolved] link to a form with preselected taxonomy value

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 3 replies, has 1 voice.

Last updated by fabriceS 3 days, 13 hours ago.

Assisted by: Minesh.

Author
Posts
#2819023

[cred_child_link_form form='14194' parent_id='[wpv-post-id item="@movie-character-name.parent"]' text='Create new' target='_self']

this is my link to a form.

In this form the user need to check boxes of the taxonomy 'performance-language".

I want to preselect the boxe with a taxonomy value. How can I do that ?

#2819024

Instead of a text "create new" I also would like to have a small svg picture as a link.

#2819026

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

What checkboxes option you want to pre-selected. What form you have to create new entry or edit exiting entry.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

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

#2819064

Minesh
Supporter

Languages: English (English )

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

Within your view I've removed the [cred_child_link_form] shortcode using which you display the "Create new" link
=> hidden link

And replaced with the following HTML link:

<a href="/add-new-cast/?parent_movie_id=[wpv-post-id item="@movie-character-name.parent"]&pl=[wpv-search-term param='pl']" target="_self">Create new</a>

You can replace the "Create new" with your required SVG.

To make the checkbox selected I've added the following custom JS code to your form's custom JS editor:
=> hidden link

jQuery(document).ready(function($){
var getUrlParameter = function getUrlParameter(sParam) {
    var sPageURL = decodeURIComponent(window.location.search.substring(1)),
        sURLVariables = sPageURL.split('&'),
        sParameterName,
        i;
    
    for (i = 0; i < sURLVariables.length; i++) {
        sParameterName = sURLVariables[i].split('=');
    
        if (sParameterName[0] === sParam) {
            return sParameterName[1] === undefined ? true : sParameterName[1];
        }
    }
};
var param = getUrlParameter('pl');
//param = param.charAt(0).toUpperCase() + param.slice(1);
 console.log(param);
   
$('input[type="checkbox"][data-value]').each(function() {
  if ($(this).data('value').toLowerCase().includes(param)) {
    $(this).prop('checked', true);
  }
});
  
});

- You can adjust the code as required if needed.

#2819068

Thanks a lot Minesh.