I have been trying to simply get form_state['value'][''] for a checkbox so I
can validate if a user agrees or not.

My simple module code:

function blocktest_user_register_form($form, &$form_state){
	$form['client terms'] = array(
        '#type' => 'checkbox',
        '#title' => t('I agree to site terms of Use.'),
        '#description' => 'By checking this box you are agreeing to site Terms of Use and Privacy Policy',
    );
return $form;
}

function blocktest_user_register_form_validate($form, &$form_state) {

	if($form_state['value']['client terms'] == 0){
      form_set_error('client terms', 'You must argee with site terms to procede');
      dsm($form_state);
    	} 
}

No mater if checkbox is checked or not the form_state['value']['client terms'] is "0". I'm I missing something fundamental with in Drupal? or
is this a bug? I am thinking that I should get "1" if user checked and "0" if left unchecked.

Please any advice would be great. I have searched (drupal, google) for a similar problem/thread with out any luck. Thank You for any help.

Comments

marshallexcavating’s picture

Changed "client terms" to "client_terms". Drupal/php dose not recognize discontinuous charters!!! Drupal did not flag a error just did not save in form_state[].

Well there went a day of head banging. Hope this thread helps some one avoid a similar problem.