0
は、私はDrupalの8で、次のように同じ名前の複数の入力フィールドを作成するにはどうすればよい同じ名前の複数のフィールドを作成し、Drupal 8でサブミットするときにその値を取得する方法は?以下
<?php
namespance Drupal\hello_world\Form;
class MailForm extends ConfigFormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
$form['email_address'] = [
'#type' => 'email',
'#title' => $this->t(
'Email address:'
),
];
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$email_address = $form_state->getValue('email_address');
}
}
のDrupal 8で私のカスタムモジュールの設定フォームのですか?
<input name="email_address[]" type="email" />
<input name="email_address[]" type="email" />
<input name="email_address[]" type="email" />
上記の入力フィールドからすべての値をDrupal 8で送信するとき、次のように取得するにはどうすればよいですか?
array(
'email_address' => array(
'0' => '[email protected]',
'1' => '[email protected]',
'2' => '[email protected]',
)
)
フォームの送信時にこれらの入力値を取得するにはどうすればよいですか? –
$ form_state-> getValue( 'email_address')は値の配列を返す必要があります –