Skip validation for a form element in Drupal
// we have to get out of validation somehow
// we have to get out of validation for an associated group somehow
You must join a group before posting on this web site.
Well, the nuclear option on case 'action_node_form':
in my implementation of hook_form_alter
works:
$form['#validate'] = array();
Now is there a way to just skip, or preset, validation for one item in the form array?
drupal
ben-agaric: Is it possible to turn off validation of a specific form element with form_alter? (Override validation from another module.) In Drupal 5.
ben-agaric: Is there a way to turn off validation for a given form element? Drupal 5 and I've successfully merged two forms, so that you can create an organic group at the same time as the first post for that group ( http://dev.wsf2008.net/ ) but the only way I've been able to kill the "you must join a group" is with $form['#validate'] = array();
hunmonk: ben-agaric: you could try unsetting the validation handler, but that might also be overkill
[2:18pm] webchick left the chat room.
[2:19pm] dww: hunmonk: yeah, you most definitely bought yourself a hell of a lot more work, take it from me.
[2:19pm] ben-agaric: hunmonk: thanks, that's what my array() does I think, and yeah, I'd like it to do all the validation, except for one piece done by organic groups in nodeapi 'insert' -- if that provides another line of attack.
ben-agaric: just to report back to myself... validation can be successfully skipped by filling in dummy values... obvious, but organic groups was doing the validation in nodeapi and I wasn't sure what it corresponded to in the formapi... I think its funky 'og_groups_hidden' field
[2:38pm] ben-agaric: first post + organic group creation, in one form. With validation. Yay me.
Resolution
// remove group choice, we'll pass this in directly
// for reference: [og_nodeapi][visible][og_groups][#type] & [#value]
unset($form['og_nodeapi']['visible']);
// we have to get out of validation for an associated group somehow
$form['og_nodeapi']['invisible']['og_groups'] = array(
'#type' => 'value',
'#value' => TRUE,
);
$form['og_nodeapi']['invisible']['og_groups_hidden'] = array(
'#type' => 'value',
'#value' => TRUE,
);
I think only the second is absolutely needed, but better safe.
This is part of the conclusion to merging forms.
Comments
Post new comment