You are here

function authcache_form_value_suspect in Authenticated User Page Caching (Authcache) 7.2

Recursively find elements of type value and flag them as suspicous.

Related topics

1 call to authcache_form_value_suspect()
authcache_form_alter in ./authcache.module
Implements hook_form_alter().

File

./authcache.module, line 322
Authenticated User Page Caching (and anonymous users, too!)

Code

function authcache_form_value_suspect(&$element, $form_id, $parents = array()) {
  if (isset($element['#type']) && $element['#type'] === 'value') {
    $name = '';
    $num_parents = count($parents);
    if (isset($element['#name'])) {
      $name = $element['#name'];
    }
    elseif ($num_parents > 0) {
      $name = $parents[0];
      if ($num_parents > 1) {
        $name .= '[' . implode('][', array_slice($parents, 1)) . ']';
      }
    }
    authcache_element_suspect($element, t('Value element %name contained in the cacheable form %form_id. Please enable a suitable Authcache integration module for that form or file a support request.', array(
      '%name' => $name,
      '%form_id' => $form_id,
    )));
  }
  foreach (element_children($element, FALSE) as $key) {
    authcache_form_value_suspect($element[$key], $form_id, array_merge($parents, array(
      $key,
    )));
  }
}