You are here

function webform_input_vars_check in Webform 7.4

Check if the last form submission exceeded the servers max_input_vars limit.

Optionally preflight the current form to be returned in this request.

Parameters

array $form: Reference to the form, which will be changed if $parent_key is set.

array $form_state: Form's state or NULL for no form state check.

string $detect_key: A key that will always be present in the posted data when an actual form submission has been made.

string $parent_key: Omit to not preflight the form, or the array key for the parent of where the preflight warning should be inserted into the form.

3 calls to webform_input_vars_check()
webform_client_form in ./webform.module
Client form generation function.
webform_components_form in includes/webform.components.inc
The table-based listing of all components for this webform.
webform_conditionals_form in includes/webform.conditionals.inc
Form builder; Provide the form for adding conditionals to a webform node.

File

./webform.module, line 5466
This module provides a simple way to create forms and questionnaires.

Code

function webform_input_vars_check(array &$form, array $form_state, $detect_key, $parent_key = NULL) {
  if (isset($parent_key)) {
    $form['#pre_render'] = array(
      'webform_pre_render_input_vars',
    );
    $form['#input_var_waring_parent'] = $parent_key;
  }
  if (!empty($form_state['input']) && array_key_exists($detect_key, $form_state['input']) && !array_key_exists('form_id', $form_state['input'])) {

    // A form was submitted with POST, but the form_id was missing. The most
    // likely cause of this is that the POST was truncated because PHP exceeded
    // its max_input_vars limit.
    $subs = array(
      '@count' => webform_count_terminals($_POST),
      '@limit' => (int) ini_get('max_input_vars'),
    );
    drupal_set_message(user_access('administer site configuration') ? t('This form could not be submitted because $_POST was truncated to @count input vars.  PHP max_input_vars is @limit and needs to be increased.', $subs) : t('This form could not be submitted because it exceeds the server configuration. Contact the administrator.'), 'error');
    watchdog('webform', 'POST truncated to @count input vars. PHP max_input_vars is @limit. Increase max_input_vars.', $subs, WATCHDOG_ERROR);
  }
}