Drupal Entity Extra Field - mind the container

You can add an extra field to a Drupal entity via hook like it is described here: https://gorannikolovski.com/blog/display-and-form-pseudo-fields-drupal-8...

There is one caveat to this explanation. If you use field groups to group such extra fields you need to put them into a container (at least for the form extra fields), otherwise they will not show inside the field group.

So instead of this

      $form['field_thank_you'] = [
        '#type' => 'markup',
        '#markup' => 'Thanks'
      ];

use

      $form['field_thank_you'] = [
        '#type' => 'container'
      ];
      $form['field_thank_you']['message'] = [
        '#type' => 'markup',
        '#markup' => 'Thanks'
      ];

Neuen Kommentar schreiben

Filtered HTML

  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • HTML - Zeilenumbrüche und Absätze werden automatisch erzeugt.
  • To post pieces of code, surround them with <code>...</code> tags. For PHP code, you can use <?php ... ?>, which will also colour it based on syntax.

Plain text

  • Keine HTML-Tags erlaubt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • HTML - Zeilenumbrüche und Absätze werden automatisch erzeugt.