forked from drupalcommerce/commerce
/
MultipleProfileSelectTestForm.php
52 lines (45 loc) · 1.45 KB
/
MultipleProfileSelectTestForm.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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()]));
}
}