Hi I can't send you our setup as we are still in development, but I just did a quick form/page test to recreate it and found an interesting result when I was using jQuery to disabled a drop down list box that was being used as a conditional statement for some check boxes.
I created a form with two fields on it, field 1 was a "drop down" with two choices set up in the editor, I enabled the values and set the values of each to 1 & 2. This is the only options I setup in the form editor for the "drop down" field. I then created a second field of type checkboxes. I enabled the values and set the values to 1,2,3 for the three default check boxes for the field. In the advanced options for this field I "Enabled Conditional Logic" So this field would "show this field is All of the following match" : "Selection(name of my drop down) is First Choice".
So a pretty simple form. Below is the PHP for this form.
[php]
<?php
/**
* @author Ben Hooper
* @copyright 2011
*/
add_filter('gform_pre_render_22', 'populateCheckBoxTest');
add_action("gform_post_submission_22", "submitCheckBoxTest", 10, 2);
/**
*Populate the form
* @param form $form The form to populate the details with
* @return the form being modified.
*/
function populateCheckBoxTest($form)
{
//run the javascript to initialise this form
echo "<script language=javascript>";
echo "jQuery(document).ready(function () {";
echo "jQuery('#input_22_1').val('1');";
//echo "jQuery('#field_22_1').css('display', 'none');"; //Hides the field and the entry works
echo "jQuery('#input_22_1').attr('disabled', 'disabled');"; //disables the input and the entry doesn't work
echo "});";
echo "</script>";
return $form;
}
/**
* Submit the form
* @param array $entry An array of objects including in the form
* @param form $form The form forming no
*/
function submitCheckBoxTest($entry, $form)
{
var_dump($entry);
}
?>
So again really basic, I've put the Javascript inline in the gform_pre_render function, I was previously calling a javascript function, but this keeps is simple. When I disable the field using ('#input_22_1').attr('disabled', 'disabled'); and submit the form the var_dump of the $entry is:
bool(false)
however when I hide the dropdown field using ('#field_22_1').css('display', 'none'); the var_dump of the $entry returns the data correctly:
e.g.
...NULL ["user_agent"]=> string(106) "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2" ["status"]=> string(6) "active" [1]=> string(1) "1" ["2.1"]=> string(1) "1" ["2.3"]=> string(1) "3" ["2.2"]=> string(0) "" }
Hope that helps, but please feel free to ask anything else.
Regards
Ben
Posted 12 years ago on Friday December 16, 2011 |
Permalink