function comment_form_field_ui_field_storage_add_form_alter

comment_form_field_ui_field_storage_add_form_alter(&$form, FormStateInterface $form_state)

Implements hook_form_FORM_ID_alter() for field_ui_field_storage_add_form.

File

core/modules/comment/comment.module, line 292
Enables users to comment on published content.

Code

function comment_form_field_ui_field_storage_add_form_alter(&$form, FormStateInterface $form_state) {
  $route_match = \Drupal::routeMatch();
  if ($form_state->get('entity_type_id') == 'comment' && $route_match->getParameter('commented_entity_type')) {
    $form['#title'] = \Drupal::service('comment.manager')->getFieldUIPageTitle($route_match->getParameter('commented_entity_type'), $route_match->getParameter('field_name'));
  }
  if (!_comment_entity_uses_integer_id($form_state->get('entity_type_id'))) {
    $optgroup = (string) t('General');
    // You cannot use comment fields on entity types with non-integer IDs.
    unset($form['add']['new_storage_type']['#options'][$optgroup]['comment']);
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!comment!comment.module/function/comment_form_field_ui_field_storage_add_form_alter/8.1.x