gpt4 book ai didi

drupal-8 - 如何将实体引用添加为表单字段 drupal 8?我有可能吗?

转载 作者:行者123 更新时间:2023-12-01 13:57:48 25 4
gpt4 key购买 nike

我想要实现的是插件的简单配置。我需要实体引用字段,用户可以在其中使用自动完成字段将某些产品添加到配置中。我尝试使用 Config Entity 但它看起来与 Form Api 相同,我不能在那里使用实体字段。
我迫不及待地想看到你的回复。

最佳答案

我能够在 Drupal 8 中使用表单 API 和 entity_autocomplete 类型做到这一点。

$form['stories'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'node',
'#title' => $this->t('Stories'),
'#description' => $this->t('Select some stories.'),
'#default_value' => $default_entities,
'#tags' => TRUE,
'#selection_settings' => array(
'target_bundles' => array('page', 'article'),
),
'#weight' => '0',
];

关于drupal-8 - 如何将实体引用添加为表单字段 drupal 8?我有可能吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38866849/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com