1
Mar 2010

Viewing the $form and $form_state arrays when working with Webforms

comment icon0 comment(s) |

Recently I was working on an additional validation script for a webform on a client's site. It was particularly frustrating because I couldn't seem to locate the variable I needed for my validation.

I didn't see this anywhere else but this helped a ton and, after figuring this out, I was able to knock out the validation script in five minutes.

Just place the following code in the "Additional Processing" field. To see the $form variable, simply switch it with $form_state in the following code snippet.

<?php

drupal_set_message(print_r($form_state));

?>

After saving this, simply fill out your webform and submit it; you should then see an entire display of the $form_state array to make validation and processing scripts a lot easier to put together. In order to view the array displayed with proper spacing, use the "View Source" option in your browser.

Subscribe to our Networks

IW on Facebook