Last active
January 2, 2023 19:41
-
-
Save junaidpv/7be66f6900660d97f36aad897c9747d2 to your computer and use it in GitHub Desktop.
It is rerolling of patch https://www.drupal.org/project/commerce/issues/3328849#comment-14850565 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 95d17db5..2acd96eb 100644 | |
| --- a/modules/checkout/config/schema/commerce_checkout.schema.yml | |
| +++ b/modules/checkout/config/schema/commerce_checkout.schema.yml | |
| @@ -78,6 +78,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..3d450889 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')) { | |
| @@ -429,7 +443,7 @@ class Login extends CheckoutPaneBase implements CheckoutPaneInterface, Container | |
| 'preferred_admin_langcode' => $this->languageManager->getCurrentLanguage()->getId(), | |
| ]); | |
| - $form_display = EntityFormDisplay::collectRenderDisplay($account, 'register'); | |
| + $form_display = EntityFormDisplay::collectRenderDisplay($account, $this->configuration['register_form_mode']); | |
| $form_display->extractFormValues($account, $pane_form['register'], $form_state); | |
| $form_display->validateFormValues($account, $pane_form['register'], $form_state); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment