diff --git a/core/modules/node/node.js b/core/modules/node/node.js index 298bcb9..1a82ea1 100644 --- a/core/modules/node/node.js +++ b/core/modules/node/node.js @@ -27,7 +27,7 @@ $context.find('.node-form-author').drupalSetSummary(function (context) { var $context = $(context); - var name = $context.find('.field-name-uid input').val() || drupalSettings.anonymous, + var name = $context.find('.field-name-uid input').val(), date = $context.find('.field-name-created input').val(); return date ? Drupal.t('By @name on @date', { '@name': name, '@date': date }) : @@ -39,7 +39,7 @@ var vals = []; if ($context.find('input').is(':checked')) { - $context.find('input:checked').parent().each(function () { + $context.find('input:checked').next('label').each(function () { vals.push(Drupal.checkPlain($.trim($(this).text()))); }); return vals.join(', '); diff --git a/core/modules/node/src/Entity/Node.php b/core/modules/node/src/Entity/Node.php index 91a39bc..3bdc9d2 100644 --- a/core/modules/node/src/Entity/Node.php +++ b/core/modules/node/src/Entity/Node.php @@ -392,7 +392,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { 'autocomplete_type' => 'tags', 'placeholder' => '', ), - )); + )) + ->setDisplayConfigurable('form', TRUE); $fields['status'] = BaseFieldDefinition::create('boolean') ->setLabel(t('Publishing status')) @@ -435,7 +436,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { 'display_label' => TRUE, ), 'weight' => -1, - )); + )) + ->setDisplayConfigurable('form', TRUE); $fields['sticky'] = BaseFieldDefinition::create('boolean') ->setLabel(t('Sticky')) @@ -448,7 +450,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { 'display_label' => TRUE, ), 'weight' => 0, - )); + )) + ->setDisplayConfigurable('form', TRUE); $fields['revision_timestamp'] = BaseFieldDefinition::create('created') ->setLabel(t('Revision timestamp')) diff --git a/core/modules/node/src/NodeForm.php b/core/modules/node/src/NodeForm.php index 4a752aa..e8bf3c5 100644 --- a/core/modules/node/src/NodeForm.php +++ b/core/modules/node/src/NodeForm.php @@ -7,6 +7,7 @@ namespace Drupal\node; +use Drupal\Component\Utility\Html; use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; @@ -77,9 +78,8 @@ protected function prepareEntity() { * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { - $form = parent::form($form, $form_state, $node); - - // Try to restore from temp store. + // Try to restore from temp store, this must be done before calling + // parent::form(). $uuid = $this->entity->uuid(); $store = $this->tempStoreFactory->get('node_preview'); @@ -104,13 +104,12 @@ public function form(array $form, FormStateInterface $form_state) { $form['#title'] = $this->t('Edit @type @title', array('@type' => node_get_type_label($node), '@title' => $node->label())); } - $current_user = \Drupal::currentUser(); - $user_config = \Drupal::config('user.settings'); + $current_user = $this->currentUser(); // Override the default CSS class name, since the user-defined node type // name in 'TYPE-node-form' potentially clashes with third-party class // names. - $form['#attributes']['class'][0] = drupal_html_class('node-' . $node->getType() . '-form'); + $form['#attributes']['class'][0] = Html::getClass('node-' . $node->getType() . '-form'); // Changed must be sent to the client, for later overwrite error checking. $form['changed'] = array( @@ -127,11 +126,14 @@ public function form(array $form, FormStateInterface $form_state) { '#access' => isset($language_configuration['language_show']) && $language_configuration['language_show'], ); + // Create the "advanced" vertical tabs before building the form, so that + // field widgets may detect its presence and choose to live there. $form['advanced'] = array( '#type' => 'vertical_tabs', '#attributes' => array('class' => array('entity-meta')), '#weight' => 99, ); + $form = parent::form($form, $form_state); // Add a revision_log field if the "Create new revision" option is checked, // or if the current user has the ability to check that option. @@ -181,24 +183,18 @@ public function form(array $form, FormStateInterface $form_state) { ), '#attached' => array( 'library' => array('node/drupal.node'), - 'js' => array( - array( - 'type' => 'setting', - 'data' => array('anonymous' => $user_config->get('anonymous')), - ), - ), ), '#weight' => 90, '#optional' => TRUE, ); - $form['uid'] += array( - '#group' => 'author', - ); + if (isset($form['uid'])) { + $form['uid']['#group'] = 'author'; + } - $form['created'] += array( - '#group' => 'author', - ); + if (isset($form['created'])) { + $form['created']['#group'] = 'author'; + } // Node options for administrators. $form['options'] = array( @@ -215,13 +211,13 @@ public function form(array $form, FormStateInterface $form_state) { '#optional' => TRUE, ); - $form['promote'] += array( - '#group' => 'options', - ); + if (isset($form['promote'])) { + $form['promote']['#group'] = 'author'; + } - $form['sticky'] += array( - '#group' => 'options', - ); + if (isset($form['sticky'])) { + $form['sticky']['#group'] = 'author'; + } return $form; }