You are here

function simplify_form_node_form_alter in Simplify 8

Same name and namespace in other branches
  1. 7.3 simplify.module \simplify_form_node_form_alter()

Implements hook_form_BASE_FORM_ID_alter() for node_form().

Overrides the node creation form to hide elements depending on settings.

File

./simplify.module, line 205
Hooks implemented by the simplify module.

Code

function simplify_form_node_form_alter(&$form, FormStateInterface $form_state) {

  // @todo This must be handled in a #process handler.
  $node = $form_state
    ->getFormObject()
    ->getEntity();
  $node_type = $node->type->entity;

  // Get array of fields to hide.
  $global_fields = _simplify_get_config_value('simplify_nodes_global');
  $type_fields = _simplify_get_config_value('simplify_nodes', [], 'simplify.content_type.' . $node_type
    ->get('type'));
  $fields = array_merge($global_fields, $type_fields);

  // Hide fields.
  simplify_hide_fields($fields, $form);
}