Created
December 20, 2022 18:15
-
-
Save junaidpv/6ae84b8fb7d84fc6dd128fc125689c34 to your computer and use it in GitHub Desktop.
To process field group settings on user register form in checkout pane.
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
| diff --git a/modules/checkout/src/Plugin/Commerce/CheckoutPane/Login.php b/modules/checkout/src/Plugin/Commerce/CheckoutPane/Login.php | |
| index 2bdc785b..b1908d91 100644 | |
| --- a/modules/checkout/src/Plugin/Commerce/CheckoutPane/Login.php | |
| +++ b/modules/checkout/src/Plugin/Commerce/CheckoutPane/Login.php | |
| @@ -282,6 +282,7 @@ class Login extends CheckoutPaneBase implements CheckoutPaneInterface, Container | |
| '#type' => 'email', | |
| '#title' => $this->t('Email address'), | |
| '#required' => FALSE, | |
| + '#weight' => -100, | |
| ]; | |
| $pane_form['register']['name'] = [ | |
| '#type' => 'textfield', | |
| @@ -296,12 +297,14 @@ class Login extends CheckoutPaneBase implements CheckoutPaneInterface, Container | |
| 'spellcheck' => 'false', | |
| ], | |
| '#default_value' => '', | |
| + '#weight' => -99, | |
| ]; | |
| $pane_form['register']['password'] = [ | |
| '#type' => 'password_confirm', | |
| '#size' => 60, | |
| '#description' => $this->t('Provide a password for the new account in both fields.'), | |
| '#required' => FALSE, | |
| + '#weight' => -98, | |
| ]; | |
| $pane_form['register']['register'] = [ | |
| '#type' => 'submit', | |
| @@ -315,6 +318,23 @@ class Login extends CheckoutPaneBase implements CheckoutPaneInterface, Container | |
| $form_display = EntityFormDisplay::collectRenderDisplay($account, 'register'); | |
| $form_display->buildForm($account, $pane_form['register'], $form_state); | |
| + if (\Drupal::moduleHandler()->moduleExists('field_group')) { | |
| + $entity = $account; | |
| + | |
| + $context = [ | |
| + 'entity_type' => $entity->getEntityTypeId(), | |
| + 'bundle' => $entity->bundle(), | |
| + 'entity' => $entity, | |
| + 'context' => 'form', | |
| + 'display_context' => 'form', | |
| + 'mode' => $form_display->getMode(), | |
| + ]; | |
| + | |
| + field_group_attach_groups($pane_form['register'], $context); | |
| + $pane_form['register']['#process'][] = [\Drupal\field_group\FormatterHelper::class, 'formProcess']; | |
| + $pane_form['register']['#pre_render'][] = [\Drupal\field_group\FormatterHelper::class, 'formGroupPreRender']; | |
| + } | |
| + | |
| return $pane_form; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment