用户如何使用自动完成字段将产品添加到简单插件配置中?
我尝试使用 Config Entity,但它看起来与 Form API 相同(并且我无法在那里使用实体字段)。
我尝试使用 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',
];
使用webform - 这里有一个实体引用字段。 这对你的目的来说不可用...但你可以为了好奇查看源代码。