[UPHPU] QuickForm and Checkboxes, is it checked?

Mitch Anderson mitch at metauser.net
Fri Nov 19 09:35:59 MST 2004

I'm running into problems in using quickform... I'm just trying to
figure out how I check to know if the checkbox was checked.  The problem
I'm having is, depending on the data in the database, the check should
be checked already.  However, If I remove the check and submit... I'm
still seeing it as being checked in my validate... If its not check in
the DB, and I check it, and submit, it works fine.  Or if its not
checked and I submit it unchecked, it comes through as still being
unchecked. I've been trying to find an example of how someone else was
using it and reading through pear.php.net[1] hasn't shed any more light
on things either... A sample of my code is below.  What am I doing

// $data_array holds result of one row from a database.
$data_array = $data_result->fetchRow(DB_FETCHMODE_ASSOC); 

$form = new HTML_QuickForm('Form');

$checked =& $form->addElement('checkbox', 'check1', NULL, 'CheckMe',
if($data_array['check1'] == 1) { $checked->setChecked(true); }
$form->addElement('submit', null, 'Submit');

	$checked = $form->exportValue('check1');

	if($checked == 1){
		$ret_array['check1'] = 1;
	} else {
		$ret_array['check1'] = 0;
} else {

[1] http://pear.php.net/manual/en/package.html.html-quickform.html-

Mitch Anderson <mitch at metauser.net>

More information about the UPHPU mailing list