Support

Home Forums Event Espresso Premium Copy above information to all forms not copying radio buttons

Copy above information to all forms not copying radio buttons

Posted: May 18, 2015 at 8:06 pm

Viewing 4 reply threads


lhammond

May 18, 2015 at 8:06 pm

I’m using EE 3.1.36.6.P, and the copy to all forms button isn’t copying the value of my gender field, which is radio buttons. I have a few other fields that are radio buttons that do get copied, but they each only have one radio button (actually, they should be checkboxes, but we tried switching them to radio buttons because we’re also having problems with form validation – they are required fields yet somehow people are getting through registration without checking them sometimes.)

Any idea why this might be failing? I looked in espresso_cart_functions.js and don’t see any obvious reason right off why it might be ignoring that field, but admittedly, I don’t understand the jQuery code all that well.


lhammond

May 18, 2015 at 8:49 pm

Also, if I wanted to hide my secondary question groups after the “copy to all forms” button is clicked, I would need to add that code to the function in espresso_cart_functions.js, right? Has anyone ever tried to do that? We have families registering multiple children for many classes (events) at once, so our registration form gets VERY long. Anything I can do to simplify it would be very helpful. Thanks!


Dean

May 20, 2015 at 3:13 am

Hi,

Thanks for reporting this, it looks liek a bug. I’ve raised a developer ticket to fix it.

Regarding the hiding, you could do it from a site specific plugin (rather than modifying core files) that loads custom jquery onto the event registration page. As this is very specific to your use case, you would need a developer to assist with the customisation.


lhammond

May 20, 2015 at 3:41 am

I fixed the problem by editing espresso_cart_functions.js. I put this code in under the “jQuery(‘.copy-all-button’).on( ‘click’, function() {” (not sure exactly what line it was because I had already made other edits to this file):

switch (input_type) {
...
case 'radio':
// make sure the whole radio group is looked at, not just the first button in the array
var genders = document.getElementsByName(copy_field_name);
for(var i = 0; i < genders.length; i++) {
   if(genders[i].checked == true) {
	selectedGender = genders[i].value;
	//console.log("found selected value: " + selectedGender);
	if (jQuery(this).val() == genders[i].value) {
	    jQuery(this).attr("checked", "checked");
	}
    }
}	    

I also figured out how to add the jQuery calls to hide the relevant fields when the copy-all button is clicked and the first instance of my fields is completed. In case it helps anybody else out, here’s the idea:

var firstrelease = jQuery("input[value='I accept the Release and Waiver.']:first");
if (firstrelease.attr("checked") == "checked") 
{
   var waiverfields = jQuery("fieldset[id='releasewaiver-1366059124']:not(:first)");
   waiverfields.hide();
}


Dean

May 20, 2015 at 4:05 am

Thanks for sharing that!

I added a *possible* fix to the ticket that is a little more general than yours:

var copy_to = jQuery(this);
jQuery(":input[name='" + copy_field_name + "']").each(function(i, e) {
    if ( jQuery(e).attr('checked') && val == jQuery(e).val()) {                            
        jQuery(copy_to).attr("checked", "checked");
    }
});
break;

That would also go under the radio case.

It hasn’t been fully tested nor accepted yet, so use at your own risk.

Viewing 4 reply threads

The support post ‘Copy above information to all forms not copying radio buttons’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso