function seven_form_node_form_alter in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/themes/seven/seven.theme \seven_form_node_form_alter()
Implements hook_form_BASE_FORM_ID_alter().
Changes vertical tabs to container and adds meta information.
File
- core/
themes/ seven/ seven.theme, line 152 - Functions to support theming in the Seven theme.
Code
function seven_form_node_form_alter(&$form, FormStateInterface $form_state) {
/** @var \Drupal\node\NodeInterface $node */
$node = $form_state
->getFormObject()
->getEntity();
$form['#theme'] = array(
'node_edit_form',
);
$form['#attached']['library'][] = 'seven/node-form';
$form['advanced']['#type'] = 'container';
$is_new = !$node
->isNew() ? format_date($node
->getChangedTime(), 'short') : t('Not saved yet');
$form['meta'] = array(
'#attributes' => array(
'class' => array(
'entity-meta__header',
),
),
'#type' => 'container',
'#group' => 'advanced',
'#weight' => -100,
'published' => array(
'#type' => 'html_tag',
'#tag' => 'h3',
'#value' => $node
->isPublished() ? t('Published') : t('Not published'),
'#access' => !$node
->isNew(),
'#attributes' => array(
'class' => 'entity-meta__title',
),
),
'changed' => array(
'#type' => 'item',
'#wrapper_attributes' => array(
'class' => array(
'entity-meta__last-saved',
'container-inline',
),
),
'#markup' => '<h4 class="label inline">' . t('Last saved') . '</h4> ' . $is_new,
),
'author' => array(
'#type' => 'item',
'#wrapper_attributes' => array(
'class' => array(
'author',
'container-inline',
),
),
'#markup' => '<h4 class="label inline">' . t('Author') . '</h4> ' . $node
->getOwner()
->getUsername(),
),
);
$form['revision_information']['#type'] = 'container';
$form['revision_information']['#group'] = 'meta';
}