On user defined nodes the "Exclude node title" form element should be in the sidebar and appear on the form mode page to allow to change its order.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

demonde created an issue. See original summary.

vaccinemedia’s picture

I totally agree - maybe not in the sidebar but definitely in the form display settings. I have for example, a content type which in the form display is split up using horizontal tabs into easier to manage chunks i.e. Main content, hero content, sidebar content etc... The exclude node title checkbox is currently appearing outside of these tabs at the bottom of the form. It would be nice to have the ability to move it to just underneath the title field OR (and maybe better still) simply have it as part of the title field.

ChandeepKhosa’s picture

Status: Active » Fixed

@vaccinemedia It does currently show up in the form display and directly under title :) I am closing this issue

vaccinemedia’s picture

Status: Fixed » Active
FileSize
247.38 KB
217.3 KB

I believe the issue here is that the exclude node title checkbox is not a part of the rest of the entity / node fields. For example I have attached two screen grabs. One is the node add / edit display and the other is the config for the same content type's form display.

As you can see on the form's config there are field groups which have been added as horizontal tabs to break the form into smaller chunks.

On the node add form, the exclude node title form element is outside of the field group / tab and appears at the bottom of the form - detached from the title which it is affecting. Looking at the form display / config there is no way to drag the exclude node title form element into the first tab. The checkbox does not (and cannot by way of config) appear in the publishing options in the right sidebar either.

Ideally the checkbox would appear with the publishing options or be a form element on the form display which can be moved.

joshua.boltz’s picture

I've also recently come across this, where i expected to see the "Exclude title from display" checkbox on a node form. I DO see the checkbox on the node add and node edit forms, which i expect because i have done the user-defined configuration work at /admin/config/content/exclude-node-title.

But, where i'm, not seeing the checkbox is on the node form when loaded via inline entity form, such as a paragraph that has an entity reference field to node bundles. When a user can create a new node in the IEF, there is no checkbox.

I believe it's not there because of this code

function exclude_node_title_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $form_object = $form_state->getFormObject();
  $exclude_manager = \Drupal::service('exclude_node_title.manager');

  if ($form_object instanceof NodeForm) {
    /** @var NodeInterface $node */

in exclude_node_title.module around like 190.

I think there needs to be a check

if ($form_object instanceof EntityBrowserForm) {

And then access the node form that's loaded within that and then apply the same adding the checkbox form element as it's doing

$form['exclude_node_title'] = array(
        '#type' => 'checkbox',
        '#field_name' => 'exclude_node_title',
        '#title' => t('Exclude title from display'),
        '#required' => FALSE,
        '#element_validate' => ['exclude_node_title_set_form_value'],
        '#default_value' => $exclude_manager->isNodeExcluded($node),
        '#weight' => $weight,
      );
steyep’s picture

I had the issue when using Exclude Node Title with Inline Entity Form. The field was not displaying because of the module only supports NodeForm form objects.

I have attached a patch that adds support for Inline Entity Form and other form display modes. The patch adds a computed field and dynamically attaches that to the user-editable content types. The field handles the permission checks and a prepare_form hook is used to determine if the title should be suppressed for the node form. This is useful because it sidesteps the need to get the entity from the NodeForm object.

steyep’s picture

Status: Active » Needs review
FileSize
7.24 KB

Based on the work done in #6, I have made some slight modifications to support configuring the position of the Exclude Node Title on the Form Display UI.

Patch attached.

steyep’s picture

FileSize
7.96 KB

Re-rolled the patch to account for the proper field widget name

steyep’s picture

FileSize
7.25 KB

Re-rolled the patch from #7 to account for the proper field widget name

steyep’s picture

FileSize
7.96 KB

Adds blank line to bottom of the patch

steyep’s picture

FileSize
7.25 KB

Adds blank line to bottom of the patch