By greenbeans on
Hi folks,
I'm trying to put together a module in Drupal 6, and I'm confused by the forms API. I have a form field that's pre-populated with a value.
If I view the form, change the value, and submit it, then inspect the $form_state array in my form_submit() function, $form_state['values']['fieldname'] contains the original pre-populated value rather than the POSTed value that the API docs suggest it will have.
On the other hand, $form_state['clicked_button']['#post']['fieldname'] appears to contain the POSTed value.
Is it safe to use this instead? Is $form_state['values'] supposed to have been validated? Am I doing something terribly, horribly wrong?
Thanks for your help!
Comments
SOLVED
I was setting #values instead of #default_values in the form definition, so they were getting overridden on each submission.
could you possibly offer any
could you possibly offer any code examples? i have this exact problem. see here
Ahh ive worked it out.. had a
Ahh ive worked it out.. had a brain fart yesterday it seems.
Please post the solution
I am having a similar problem $form_state doesn't retain its values when traversing to the next page. Would appreciate if you could post a note on how you solved it.
Acer Aspire 5745
[i5 430M, 3GB, 320GB]
Ubuntu 12.04 (Precise Pangolin)
Drupal 6.15, 7.x
DigitalOcean, Go Daddy, Rackspace,
$form_state['storage']