I have a form element with #access = FALSE. I'm trying to set the value of this element during form validation using form_set_value(). This works when #access = TRUE, but not when #access = FALSE (although even then the change is showing up in $form_state['values']. I suspect later on in form processing the default form value is being used instead of the altered value in $form_state['values'].

How can I set this element's value during validation such that the correct value will be passed to the form submit handler(s)?

  • Just to make sure - you passed $form_state by reference (&$form_state, right ?). and make sure you set #value, and not #default_value.
    – AKS
    Commented Jan 11, 2013 at 16:07
  • I tried using form_set_value() for a form element with #access set to FALSE, and it works: The value the form submission handler finds in $form_state['values'] is the value set with form_set_value().
    – apaderno
    Commented Jan 11, 2013 at 16:50
  • Thanks for verifying this worked for you kiamlaluno. It's worked for me in the past as well. The problem must lie elsewhere...
    – mesch
    Commented Jan 11, 2013 at 17:07


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.