public function TriggeringElementProgrammedUnitTest::buildForm in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Form/TriggeringElementProgrammedUnitTest.php \Drupal\system\Tests\Form\TriggeringElementProgrammedUnitTest::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- core/
modules/ system/ src/ Tests/ Form/ TriggeringElementProgrammedUnitTest.php, line 34 - Contains \Drupal\system\Tests\Form\TriggeringElementProgrammedUnitTest.
Class
- TriggeringElementProgrammedUnitTest
- Tests detection of triggering_element for programmed form submissions.
Namespace
Drupal\system\Tests\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form['one'] = array(
'#type' => 'textfield',
'#title' => 'One',
'#required' => TRUE,
);
$form['two'] = array(
'#type' => 'textfield',
'#title' => 'Two',
'#required' => TRUE,
);
$form['actions'] = array(
'#type' => 'actions',
);
$user_input = $form_state
->getUserInput();
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => 'Save',
'#limit_validation_errors' => array(
array(
$user_input['section'],
),
),
// Required for #limit_validation_errors.
'#submit' => array(
array(
$this,
'submitForm',
),
),
);
return $form;
}