[development] Stupid forms/node API question

Karoly Negyesi karoly at negyesi.net
Sat Dec 10 23:24:47 UTC 2005


On Sat, 10 Dec 2005 23:18:11 +0100, Syscrusher <scott at 4th.com> wrote:

First. The subject is wrong, there are no stupid questions. We all learn.

>    displays correctly.

Good!


> 2. When a preview is submitted, I need to take the value that comes from  
> $_POST and edit it before the form is generated. This is where things  
> are breaking down.

Not good.

> $form, but
> somehow it's getting set back to the original $_POST contents from that  
> field,
> between when I build the $form array and when that array is turned into  
> HTML.
>
> I've been all over the code, but I can't seem to find where that's  
> happening.
>
> Can someone help? Thanks!

Well, the actual value is calculated from $_POST['edit'] values and  
#default_value . If there is a _POST value, then it overwrites the  
#default_value .

There are at least two solutions:

a) You change $_POST
b) You add a #value to the form element in this case. Have you read the  
documentation that you should never use #value? This is the exception.  
However, be extremely cautious what you set here, it'll be sent back to  
the user.

Regards

NK

Ps. Ber, if I have not answered you, then sorry! I missed your letter.


More information about the development mailing list