Closed (fixed)
Project:
Drupal core
Version:
5.7
Component:
forms system
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Created:
1 Jul 2008 at 16:46 UTC
Updated:
23 Jul 2008 at 10:56 UTC
I ran into this on accident and I'm not sure how to prevent this. Basically, I've got a couple of hidden fields on an input form and whenever the validate function fails, the fields that were previously hidden are shown. I've tried adding
['field']['0']['value']['#type'] = "hidden"
to the validation function but that doesn't work as it does in form_alter.
Is this a bug or am I just doing something stupid?
Thanks!
Comments
Comment #1
wim leersI'm afraid you're doing something stupid. The validation function can't simply change the form:
function yourmodule_formname_validate($form_id, $form_values).You can't alter your form in the validation stage, it's as simple as that. You *can* set values though (form_set_value()) and set errors (form_set_error()/form_error()).
Comment #2
bishopbooyah commentedHi Wim,
But why is the form hidden attribute being changed during the validation function?
Thanks!
Comment #3
bishopbooyah commentedComment #4
wim leersThat must be a flaw in your code. If you debug your code step-by-step, I'm sure you'll find it ;)
Comment #5
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.