function hook_webform_element_access in Webform 8.5
Same name and namespace in other branches
- 6.x webform.api.php \hook_webform_element_access()
Check and set an element's #access property and/or return access.
Parameters
string $operation: An element create, view, or update operation.
array $element: Webform specific element properties include:
- #webform: The element's parent webform ID.
- #webform_submission: The element's related webform submission ID.
- #webform_id: The element's unique webform key.
- #webform_key: The element's webform key/name.
- #webform_parent_key: The element's parent key/name.
- #webform_parent_flexbox: TRUE if the element's parent is a flexbox container.
- #webform_depth: The depth level of the element in the form's tree hierarchy.
- #webform_children: An array of child element keys/names.
- #webform_multiple: TRUE if element stores multiple values.
- #webform_composite: TRUE if element stores composite values.
- #webform_parents: An array containing the element's parent keys/names.
Webform specific composite sub-element properties include:
- #webform_composite_id: The composite sub-element's ID.
- #webform_composite_key: The composite sub-element's parent key and element key.
- #webform_composite_parent_key: The composite sub-element's parent key.
Sub-element's can have properties defined using #SUB_ELEMENT__PROPERTY. For example, an other element's placeholder can be defined using the #other__placeholder property.
\Drupal\Core\Session\AccountInterface|null $account: (optional) If provided, only those formats that are allowed for this user account will be returned. All enabled formats will be returned otherwise. Defaults to NULL.
array $context: The element's current context which include the webform and webform submission entity.
Return value
\Drupal\Core\Access\AccessResult The access provided. Return neutral if no change.
1 function implements hook_webform_element_access()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- webform_group_webform_element_access in modules/
webform_group/ webform_group.module - Implements hook_webform_element_access().
1 invocation of hook_webform_element_access()
- WebformElementBase::checkAccessRules in src/
Plugin/ WebformElementBase.php - Check element access (rules).
File
- ./
webform.api.php, line 266 - Hooks related to Webform module.
Code
function hook_webform_element_access($operation, array &$element, \Drupal\Core\Session\AccountInterface $account = NULL, array $context = []) {
// Load the current webform and submission for element's context.
$webform = $context['webform'];
$webform_submission = $context['webform_submission'];
return !empty($element['#confidential']) ? \Drupal\Core\Access\AccessResult::forbidden() : \Drupal\Core\Access\AccessResult::neutral();
}