As we know that entity type node has preview button option which can be used during adding or editing of a node, to preview content.

enter image description here

Same feature is missing in case of Taxonomy entity.

If I want to add this feature where should I look into or is there any module available to achieve this?


Preview button added by node module in NodeForm as action in actions method:

$element['preview'] = [
      '#type' => 'submit',
      '#access' => $preview_mode != DRUPAL_DISABLED && ($node->access('create') || $node->access('update')),
      '#value' => t('Preview'),
      '#weight' => 20,
      '#submit' => ['::submitForm', '::preview'],

The Taxonomy entity form created by TermForm.php so i think you should:

  1. Extends TermForm.php in another Class.
  2. Add actions method.
  3. Create a preview method like the node preview method but for the term.
  4. Add a route subscriber to tell drupal to load your form not the default.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.