public static function Dazzler::formAlter in Formdazzle! 2.x
Alters forms to add a late-running pre-render function.
Parameters
array $form: An associative array containing the structure of the form.
string $form_id: The form id.
5 calls to Dazzler::formAlter()
- DazzlerTest::providerPreRenderForm in tests/
src/ Unit/ DazzlerTest.php - Data provider for testPreRenderForm().
- DazzlerTest::providerRepeatedPreRenderFormCalls in tests/
src/ Unit/ DazzlerTest.php - Data provider for testRepeatedPreRenderFormCalls().
- DazzlerTest::testFormAlter in tests/
src/ Unit/ DazzlerTest.php - @covers ::formAlter
- DazzlerTest::testPreRenderFormNoDebugging in tests/
src/ Unit/ DazzlerTest.php - @covers ::preRenderForm
- formdazzle_form_alter in ./
formdazzle.module - Implements hook_form_alter().
File
- src/
Dazzler.php, line 46
Class
- Dazzler
- A class providing methods to modify Drupal form elements.
Namespace
Drupal\formdazzleCode
public static function formAlter(array &$form, $form_id) {
// Instead of altering the form now, we wait until all hook_form_alter
// functions are completed and make our changes during the #pre_render
// phase of Drupal\Core\Render\Renderer::render().
$form['#formdazzle'] = [
'form_id' => $form_id,
];
// Add our pre-render function to the end of the list.
if (!isset($form['#pre_render'])) {
$form['#pre_render'] = [];
}
$form['#pre_render'][] = [
self::class,
'preRenderForm',
];
}