What code is responsible for adding - in front of taxonomy term sublevels on a taxonomy field in a node edit form?


Even though the most non-intrusive way to override it is preferred, I'm comfortable even with core patches.

  • 1
    @leymannx thank you for trying to improve the question but I'm not trying to remove them, I wanted to change the style. For now I've set it to '└ ' for example – int_ua Jan 29 at 13:20
  • 1
    Ah yeah, good! Clarification always is an exchange. 👍 – leymannx Jan 29 at 13:44

Looks like there is no easy way to override them, they are added by TermSelection::getReferenceableEntities in core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php:73:

$options[$vocabulary->id()][$term->id()] = str_repeat('-', $term->depth) . Html::escape($this->entityRepository->getTranslationFromContext($term)->label());

If you decide to edit it, I suggest using a Composer patch system afterwards if you are using Composer.


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.