So here's the problem: I made a custom module wich adds a few extra fields to registration form, one of wich is hidden. When I validate the user data, I want to change the value of that hidden field. How cand I do that (Assuming that the form has errors and the user should fill in the error fields)? Because the $edit and $account parameters are empty when $op = "register"

Basicaly, I need to use a variable from user validation in the user registration form.

Here's what I tried so far:

if($op == "register") {
  $form["myhiddenval"] = array(
    "#type" => "hidden",
    "#default_value" => $edit["myhiddenval"]
  );
}

if($op == "validate") {
  $edit["myhiddenval"] = "some hidden value";
}

Any ideeas?

Comments

jaypan’s picture

What are you trying to do with this hidden field?

Contact me to contract me for D7 -> D10/11 migrations.

mariusilie’s picture

I need to save the file ID ($file->fid) of an uploaded image. If an user uploads an image but the form doesn't pass validation, I would like to keep the image so the user doesn't have to upload a new image each time the form is displayed.