Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

checkbox values using setField and $_ POST


This topic is 5834 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

hello..

i have a form with several checkboxes available for each hotel room night:

Nite_1_Check

Nite_2_Check

...

if i submit the form WITH a box checked, no problem. If i don't select the box and submit, it errors out "Notice: Undefined index: Nite_1_Check... Here's what i started with:


$edit->setField('Nite_1_Check', $_POST['Nite_1_Check']);





when that didn't work (if unchecked), i tried several variations of:





if ($_POST['Nite_1_Check'] != NULL) {

  $edit->setField('Nite_1_Check', $_POST['Nite_1_Check']);

  } else {

  $edit->setField('Nite_1_Check', NULL);

}

but that doesn't work. Since all of my other (non- checkbox) fields work fine, i have a feeling this has something to do with PHP not being able to send/POST a NULL value(?). Am i approaching this right?

thanks..

Posted

got it.. i had to use an "isset"


if (isset($_POST['Nite_1_Check'])) {

	$edit->setField('Nite_1_Check', $_POST['Nite_1_Check']);

		} else {

	$edit->setField('Nite_1_Check', NULL);

	}

works great.. hooray for trial/error :

This topic is 5834 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.