form_test.module
Same filename in other branches
File
-
core/
modules/ system/ tests/ modules/ form_test/ form_test.module
View source
<?php
/**
* @file
* Helper module for the form API tests.
*/
declare (strict_types=1);
use Drupal\Core\Form\FormStateInterface;
/**
* Create a header and options array. Helper function for callbacks.
*/
function _form_test_tableselect_get_data() {
$header = [
'one' => t('One'),
'two' => t('Two'),
'three' => t('Three'),
'four' => t('Four'),
];
$options['row1'] = [
'title' => [
'data' => [
'#title' => t('row1'),
],
],
'one' => 'row1col1',
'two' => t('row1col2'),
'three' => t('row1col3'),
'four' => t('row1col4'),
];
$options['row2'] = [
'title' => [
'data' => [
'#title' => t('row2'),
],
],
'one' => 'row2col1',
'two' => t('row2col2'),
'three' => t('row2col3'),
'four' => t('row2col4'),
];
$options['row3'] = [
'title' => [
'data' => [
'#title' => t('row3'),
],
],
'one' => 'row3col1',
'two' => t('row3col2'),
'three' => t('row3col3'),
'four' => t('row3col4'),
];
return [
$header,
$options,
];
}
/**
* Submit callback that just lets the form rebuild.
*/
function form_test_user_register_form_rebuild($form, FormStateInterface $form_state) {
\Drupal::messenger()->addStatus('Form rebuilt.');
$form_state->setRebuild();
}
/**
* Ajax callback that returns the form element.
*/
function form_test_tableselect_ajax_callback($form, FormStateInterface $form_state) {
return $form['tableselect'];
}
Functions
Title | Deprecated | Summary |
---|---|---|
form_test_tableselect_ajax_callback | Ajax callback that returns the form element. | |
form_test_user_register_form_rebuild | Submit callback that just lets the form rebuild. | |
_form_test_tableselect_get_data | Create a header and options array. Helper function for callbacks. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.