Created
October 19, 2018 14:50
-
-
Save DanLaufer/8a1a5e9d6c4e01d5fe3557ba4d1ab262 to your computer and use it in GitHub Desktop.
Drupal 8 - Pass arguments to buildForm()
This file contains hidden or 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