You are here

function simple_access_form_node_form_alter in Simple Access 8.3

Same name and namespace in other branches
  1. 7.2 simple_access.module \simple_access_form_node_form_alter()

Implements hook_form_FORM_ID_alter().

For node_form.

File

./simple_access.module, line 270
Builds simple access definition for content access.

Code

function simple_access_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) {

  /** @var \Drupal\node\Entity\Node $node */
  $node = $form_state
    ->getFormObject()
    ->getEntity();

  // Build the simple access form.
  if ($simple_access_form = simple_access_form($node
    ->bundle(), $node->simple_access)) {
    $simple_access_form['simple_access']['#group'] = 'advanced';
    $form = array_merge($form, $simple_access_form);
    $form['#entity_builders'][] = 'simple_access_form_node_form_builder';
  }
}