2

I have a form on my site. Users fill out the form and submit it. When I want to target one of the fields in the form with a custom module I'd target it with something like the following:

$form['customer_profile_billing']['field_organization'];

But, if I want to target the value a user entered - after they clicked submit, in a custom module, what would be the proper syntax to use, or how would I figure out what my $POST variables are?

3

The submitted values are available in your custom validate/submit handler in the $form_state['values'] or $form_state['input'] (with the later one storing raw and unvalidated user input). I think this is considered better practice than accessing the values through the $POST variable.

  • 1
    Yes, $form_state['values'] is the preferred place to get posted form values 99.9% of the time. – rooby Apr 15 '16 at 6:07

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.