如果在 Drupal 7 中选择了子术语,如何自动选择分类法父术语?

发布于 2024-12-29 11:24:50 字数 241 浏览 1 评论 0原文

我有一个显示为清单的词汇表,其中包含父项和子项术语,例如:

  • Parent 1
    • 子1.1
    • 子1.2
  • Parent 2
    • Child2.1
    • Child2.2
    • 子2.3

我的要求是默认禁用父项。如果用户选择任何子术语,则会自动选择父术语。

建议?

I have a vocabulary displayed as checklist that has both parent and child terms like:

  • Parent 1
    • Child1.1
    • Child1.2
  • Parent 2
    • Child2.1
    • Child2.2
    • Child2.3

My requirement is to have the parent term disabled by default. In case user selects any of the child term, the parent gets automatically selected.

Suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

匿名。 2025-01-05 11:24:50

You can modify the value of the reference field on save. If node entity use hook_node_presave().
First get the original tid & load it using taxonomy_term_load() to get term object, get parent id from that and replace it in the reference field.

嘿咻 2025-01-05 11:24:50

术语参考树小部件模块提供了一个用于选择术语的漂亮界面,并提供了一个在以下情况下选择父术语的选项:选择孩子。

The Term Reference Tree Widget Module provides a nice interface for selecting terms and gives an options to select the parent term when selecting the child.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文