How to see if checkbox has been checked in PHP

Hey I’m writing some code to calculate some fields and then submit them back into the website at the end using the gform_pre_submission action. I have got the number input fields fine using rgpost( ‘input_1’) etc but I am really struggling with checkboxes. I am looking to.

  1. Pull in checkbox values
  2. See whether a checkbox value has been ticked

I have looked everywhere and can’t seem to find the proper answer, any help would be much appreciated.

You can use rgpost but you do have to access each checkbox choice/input separately. For example, if your checkbox field id is 2 you would access its input values like so:

$choice1 = rgpost( 'input_2_1' );
$choice2 = rgpost( 'input_2_2' );

$choice1 will contain the choice value when selected and will be empty when not selected.

1 Like

brilliant @richardw8k appreciate it

1 Like