将实体引用添加到 Drupal 8 表单字段?
Add Entity Reference to Drupal 8 Form Field?
用户如何使用自动完成字段将产品添加到简单的插件配置?
我尝试使用 Config Entity,但它看起来与 Form API 一样(我不能在那里使用实体字段)。
使用webform - 有一个实体引用字段。
这不能用于您的目的..但您可以检查来源。
我能够在 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',
];
用户如何使用自动完成字段将产品添加到简单的插件配置?
我尝试使用 Config Entity,但它看起来与 Form API 一样(我不能在那里使用实体字段)。
使用webform - 有一个实体引用字段。 这不能用于您的目的..但您可以检查来源。
我能够在 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',
];