Drupal has a bug that it does not validate checkbox on profile form. I found a checkbox validate module that helped me solve that.
Now the problem is i have a terms and condition checkbox on profile registration form. It should not appear on edit profile page.
I over rided the template.php file with below contents.
/**
* Theme override for user edit form.
*
* The function is named themename_formid.
*/
function garland_user_profile_form($form) {
$output = '';
// Print out the $form array to see all the elements we are working with.
//$output .= dsm($form);
// Once I know which part of the array I'm after we can change it.
// You can use the normal Form API structure to change things, like so:
// Change the Username field title to Login ID.
$form['registration']['profile_address1']['#title'] = t('Login ID');
$form['registration']['profile_terms']['#value'] =1;
//removes the field from the profile edit page
//profile_terms is the name of the checkbox field..
unset($form['registration']['profile_terms']);
// Make sure you call a drupal_render() on the entire $form to make sure you
// still output all of the elements (particularly hidden ones needed
// for the form to function properly.)
$output .= drupal_render($form);
return $output;
}
When i do this, the field is not displayed on the edit profile page.But on submitting it validates and says checkbox not set.
Im a newb to drupal... Pls help...
Comments
Comment #1
ainigma32 commentedWouldn't that module still expect the checkbox to be set?
And what is the name of that module?
- Arie
Comment #2
Sandymaguire commentedHi,
Here is where i got the module with the name "Checkbox Validate".
http://drupal.org/project/checkbox_validate
yes, even after i unset the field using the above code, from displaying on the edit form it is still expecting to be set.
Thank you.
Comment #3
dave reidDuplicate of #179932: Required radios/checkboxes are not validated.