What is the best way programmatically to see if I am on the first load of a webform (the initial load before the user hits submit).

I am currently doing something like:

function webform_hook_form_alter(&$form, &$form_state, $form_id) {
	if(empty($form_state['input'])) {
		// First pass
	} else {
		// Submitted at least once (and has not passed validation)
	}

}

I don't want to lean on webform_hook_form_alter and empty($form_state['input']) if this will change in future versions.

Comments

quicksketch’s picture

You can check the page number in $form_state['webform']['page_num'].

quicksketch’s picture

Ah, well I misread your question. Checking for the presence of $form_state['submitted'] I think is the common approach for checking if *any* form in Drupal has been submitted and is doing processing.

jmoyles’s picture

Status: Active » Closed (works as designed)

Thanks quicksketch!

jmoyles’s picture

Issue summary: View changes

Removed a line of extraneous code