By webastien on
Hi all,
I hope to post in the correct section...
Excuse me in advance for my bad english, I'm french and very tired...
I've recently discovered Drupal and really enjoy this tool, but I don't understand how to modify posted values in the validate function...
I saw "form_set_value()" can modify values which will be transmitted in the submit process,
but in the case of an error appears in validate, these modifications are lost !
How could I do to set new values accessible in the form redisplayed ?
See ya.
Sébastien
Comments
The magic third argument
I just spent some time this afternoon figuring this out. Declare you validation function with 3 arguments, something like this
then when using drupal_set_value() use $form, something like this
Thanks for your reply but
Thanks for your reply but I've already use "form_set_value".
When the form are redisplayed, "some_element_name" has the old value and not "$the_value_you_want_to_set".
If I force the validate function to be true, "$the_value_you_want_to_set" is take in consideration...
I'll try again in this way if you've got good results with this function.
Ok, works in "forward" direction
I tried setting a visible field on the form then forced an error and on returning to the edit screen the value did not reflect the call to drupal_set_value().
On the other hand, if there are no errors and I set a value the submit function sees the value set.
Exactly, you explain better
Exactly, you explain better than me the problem ;)
I search a way some hours, I hope someone could explain us if there is a solution.