form_validate allow for custom errors to get passed validation?
Hi, I added a module_comment_form_validate() for my module to validate something.
I used module_form_alter() to add a:
<?php
$form['lastname'] = array(
'#type' => 'textfield',
'#title' => t('lastname'),
'#size' => 60,
'#maxlength' => 64,
'#description' => t('name'),
'#weight' => -10
);
?>Then, I validate, in comment_form_validate hook, by:
<?php
if(empty($form_state['values']['lastname'])){
form_set_error($form, t('Error.'));
return;
}
?>But this gives me the error:
•warning: Illegal offset type in isset or empty in /t/includes/form.inc on line 798.
•warning: Illegal offset type in /t/includes/form.inc on line 799.
•Error.
And the comment still goes to unpublished comments!!!!
I know that I can use #required => True, but I want something specific like this. Why won't it work????
How do I make it so, validation fails and sets form error and DOES NOT submit the comment?
PLEASE NOTE: Ajax comments module is enabled, perhaps it has something to do with it. But when I leave "email" blank, it will give an error, and it wont submit and no errors like the above. So it seems to be specific to my code above and does not deal with AJax comments.

Ok I figured it out... You
Ok I figured it out... You cant put $form in first parameter of form_set_error. I dont know why a website told me to do that.
Next time, I won't believe stupid websites that don't know how to use these functions.
-
Computer Engineer from Virginia Tech