Forked from DanLaufer/Drupal 8 - Pass arguments to buildForm()
Created
April 19, 2024 20:04
-
-
Save nickopris/44bdf701d7f216996dbd6a4ab718cbce to your computer and use it in GitHub Desktop.
Drupal 8 - Pass arguments to buildForm()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in preprocessing.php | |
$variables['lead_form'] = | |
\Drupal::formBuilder()->getForm('Drupal\my_form_module\Form\LeadForm', 'hero_video'); | |
//it passes that extra variable through getForm into an arguments array added on the end of buildForm | |
public function buildForm(array $form, FormStateInterface $form_state, string $gated_content_context = NULL) { | |
if($gated_content_context === 'hero_video') { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment