Skip to content

Instantly share code, notes, and snippets.

@DanLaufer
Created October 19, 2018 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save DanLaufer/8a1a5e9d6c4e01d5fe3557ba4d1ab262 to your computer and use it in GitHub Desktop.
Save DanLaufer/8a1a5e9d6c4e01d5fe3557ba4d1ab262 to your computer and use it in GitHub Desktop.
Drupal 8 - Pass arguments to buildForm()
// 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