Hi,
I'm making a module for Drupal 4.6, and i have some trouble with validation.
I know 4.7 is better for forms, but i'm obliged to use 4.6 for this project.
The way i see it, there should be 2 ways to validate radiobuttons:
$sem_options = array(1 => "1st semester", 2 => "2nd semester");
$output .= form_radios(t('Semester'), 'semesterID', $node->semesterID , $sem_options, '', TRUE, NULL);
This is the code i have now, and the last TRUE sets the $required parameter to true.
However, when i submit a new node and select none of the 2 radiobuttons, the node gets submitted anyway and no error is triggered.
Then i thought i could set the $required to FALSE and check in the hook_validate() if a radiobutton was selected.
if($node->semesterID == NULL){
form_set_error('semesterID', t('No semester selected.'));
}
This code does trigger an error when none is selected, but now i have the following weird behaviour:
When i go to 'create content' to make a new node, the validation already gets triggered before i submitted anything, and there's already an error displayed 'No semester selected', even though i didn't even had the change to select anything in the first place...
Does anyone know the best way to solve this issue?
I've searched on the forums and the handbooks, but all i find is 4.7 FormsAPI stuff, which is useless in my case