public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
$config = $this->config('category_dynamic_block.settings');
$form['section_title'] = array(
'#type' => 'textfield',
'#title' => $this->t('Section Title'),
'#description' => $this->t('Enter a Section Title'),
);
$form['term_name'] = array(
'#type' => 'entity_autocomplete',
'#target_type' => 'taxonomy_term',
'#selection_settings' => [
'target_bundles' => array('categories'),
],
'#title' => $this->t('Term Name'),
'#description' => $this->t('Enter a Category Vocab Term Name'),
);
$form['page_title'] = array(
'#type' => 'entity_autocomplete',
'#target_type' => 'node',
'#selection_settings' => [
'target_bundles' => array('article'),
],
'#title' => $this->t('Page Title (' . $i . ')'),
'#description' => $this->t('Enter Page Title to be displayed'),
);
return $form;}
我正在创建一个配置表单,我试图找出drupal 8中是否有一种方法允许用户为$ form ['page_title']字段输入多个值。
答案 0 :(得分:-1)
这个问题(带有表单api的无限制文本字段)可能就是您要找的内容:https://drupal.stackexchange.com/questions/208012/unlimited-textfields-with-form-api
基本上你需要添加一些ajax:
<table>
<tbody>
<tr>
<td>
<div class="hover">Hover me</div>
</td>
</tr>
<tr>
<td>
<div class="hover">Hover me</div>
</td>
</tr>
<tr>
<td>
<div class="hover">Hover me</div>
</td>
</tr>
</tbody>
</table>