forked from drupalcommerce/commerce
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #2844920 by johnhuang0808: Make multiple commerce_profile_selec…
…t form elements available in the same form and so one.
- Loading branch information
1 parent
3d70f0e
commit 57c1117
Showing
7 changed files
with
693 additions
and
54 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
52 changes: 52 additions & 0 deletions
52
modules/order/tests/modules/commerce_order_test/src/Form/MultipleProfileSelectTestForm.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Drupal\commerce_order_test\Form; | ||
|
||
|
||
use Drupal\Core\Form\FormBase; | ||
use Drupal\Core\Form\FormStateInterface; | ||
|
||
class MultipleProfileSelectTestForm extends FormBase { | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getFormId() { | ||
return 'multiple_commerce_profile_select_element_test_form'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function buildForm(array $form, FormStateInterface $form_state) { | ||
$form['profile1'] = [ | ||
'#type' => 'commerce_profile_select', | ||
'#default_value' => NULL, | ||
'#profile_type' => 'customer', | ||
'#owner_uid' => \Drupal::currentUser()->id(), | ||
'#available_countries' => ['TW', 'HU', 'FR', 'US', 'RS', 'DE'], | ||
]; | ||
$form['profile2'] = [ | ||
'#type' => 'commerce_profile_select', | ||
'#default_value' => NULL, | ||
'#profile_type' => 'customer', | ||
'#owner_uid' => \Drupal::currentUser()->id(), | ||
'#available_countries' => ['TW', 'HU', 'FR', 'US', 'RS', 'DE'], | ||
]; | ||
$form['submit'] = [ | ||
'#type' => 'submit', | ||
'#value' => $this->t('Submit'), | ||
]; | ||
|
||
return $form; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function submitForm(array &$form, FormStateInterface $form_state) { | ||
$profile1 = $form_state->getValue('profile1'); | ||
$profile2 = $form_state->getValue('profile2'); | ||
drupal_set_message($this->t('Profile1 selected: :label', [':label' => $profile1->label()])); | ||
drupal_set_message($this->t('Profile2 selected: :label', [':label' => $profile2->label()])); | ||
} | ||
} |
This file contains 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
Oops, something went wrong.