You are here

function hook_webform_view_alter in Webform 7.4

Modify the how a view was expanded to show all the components.

This alter function is only called when the view is actually modified. It provides modules an opportunity to alter the changes that webform made to the view.

This hook is called from webform_views_pre_view. If another module also changes views by implementing this same views hook, the relative order of execution of the two implementations will depend upon the module weights of the two modules. Using hook_webform_view_alter instead guarantees an opportunity to modify the view AFTER webform.

Parameters

object $view: The view object.

string $display_id: The display_id that was expanded by webform.

array $args: The arguments that were passed to the view.

Related topics

1 invocation of hook_webform_view_alter()
webform_views_pre_view in views/webform.views.inc
Implements hook_view_pre_view().

File

./webform.api.php, line 1406
Sample hooks demonstrating usage in Webform.

Code

function hook_webform_view_alter($view, $display_id, array $args) {

  // Don't show component with cid == 4.
  $fields = $view
    ->get_items('field', $display_id);
  foreach ($fields as $id => $field) {
    if (isset($field['webform_cid']) && $field['webform_cid'] == 4) {
      unset($fields[$id]);
    }
  }
  $view->display[$display_id]->handler
    ->set_option('fields', $fields);
}