Created
December 22, 2022 15:23
-
-
Save junaidpv/3b181b17586de5884b81a01f96718715 to your computer and use it in GitHub Desktop.
It is rerolling of patch https://www.drupal.org/project/commerce/issues/3328849#comment-14840464 to apply over other patches already applied there.
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/config/schema/commerce_checkout.schema.yml b/modules/checkout/config/schema/commerce_checkout.schema.yml | |
| index a3ae1bcf..680b8ef6 100644 | |
| --- a/modules/checkout/config/schema/commerce_checkout.schema.yml | |
| +++ b/modules/checkout/config/schema/commerce_checkout.schema.yml | |
| @@ -75,6 +75,9 @@ commerce_checkout.commerce_checkout_pane.login: | |
| register_form_title: | |
| type: string | |
| label: 'Title For New Customer Form' | |
| + register_form_mode: | |
| + type: string | |
| + label: 'Register Form Mode' | |
| commerce_checkout.commerce_checkout_pane.order_summary: | |
| type: commerce_checkout_pane_configuration | |
| diff --git a/modules/checkout/src/Plugin/Commerce/CheckoutPane/Login.php b/modules/checkout/src/Plugin/Commerce/CheckoutPane/Login.php | |
| index 2e41aae8..394f2f34 100644 | |
| --- a/modules/checkout/src/Plugin/Commerce/CheckoutPane/Login.php | |
| +++ b/modules/checkout/src/Plugin/Commerce/CheckoutPane/Login.php | |
| @@ -127,6 +127,7 @@ class Login extends CheckoutPaneBase implements CheckoutPaneInterface, Container | |
| 'allow_registration' => FALSE, | |
| 'returning_customer_form_title' => '', | |
| 'register_form_title' => '', | |
| + 'register_form_mode' => 'register', | |
| ] + parent::defaultConfiguration(); | |
| } | |
| @@ -181,6 +182,18 @@ class Login extends CheckoutPaneBase implements CheckoutPaneInterface, Container | |
| '#title' => $this->t('Title For New Customer Form'), | |
| '#default_value' => $this->configuration['register_form_title'], | |
| ]; | |
| + $form_modes = \Drupal::service('entity_display.repository') | |
| + ->getFormModes('user'); | |
| + $form_mode_options = []; | |
| + foreach ($form_modes as $form_mode_id => $form_mode) { | |
| + $form_mode_options[$form_mode_id] = $form_mode['label']; | |
| + } | |
| + $form['register_form_mode'] = [ | |
| + '#type' => 'select', | |
| + '#title' => $this->t('Register Form Mode'), | |
| + '#default_value' => $this->configuration['register_form_mode'], | |
| + '#options' => $form_mode_options, | |
| + ]; | |
| return $form; | |
| } | |
| @@ -197,6 +210,7 @@ class Login extends CheckoutPaneBase implements CheckoutPaneInterface, Container | |
| $this->configuration['allow_registration'] = !empty($values['allow_registration']); | |
| $this->configuration['returning_customer_form_title'] = $values['returning_customer_form_title']; | |
| $this->configuration['register_form_title'] = $values['register_form_title']; | |
| + $this->configuration['register_form_mode'] = $values['register_form_mode']; | |
| } | |
| } | |
| @@ -332,7 +346,7 @@ class Login extends CheckoutPaneBase implements CheckoutPaneInterface, Container | |
| /** @var \Drupal\user\UserInterface $account */ | |
| $account = $this->entityTypeManager->getStorage('user')->create([]); | |
| - $form_display = EntityFormDisplay::collectRenderDisplay($account, 'register'); | |
| + $form_display = EntityFormDisplay::collectRenderDisplay($account, $this->configuration['register_form_mode']); | |
| $form_display->buildForm($account, $pane_form['register'], $form_state); | |
| if (\Drupal::moduleHandler()->moduleExists('field_group')) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment