AddressBookForm.php in Ubercart 8.4
File
uc_order/src/Form/AddressBookForm.php
View source
<?php
namespace Drupal\uc_order\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
class AddressBookForm extends FormBase {
public function getFormId() {
return 'uc_order_address_book_form';
}
public function buildForm(array $form, FormStateInterface $form_state, $uid = 0, $type = 'billing', $func = '') {
$select = uc_select_address($uid, $type, $func);
if ($uid == 0) {
$form['desc'] = [
'#prefix' => '<br />',
'#markup' => $this
->t('You must select a customer before address<br />information is available.<br />'),
'#suffix' => '<br />',
];
}
elseif (is_null($select)) {
$form['desc'] = [
'#prefix' => '<br />',
'#markup' => $this
->t('No addresses found for customer.'),
'#suffix' => '<br />',
];
}
else {
$form['addresses'] = uc_select_address($uid, $type, $func, $this
->t('Select an address'));
$form['addresses']['#prefix'] = '<div style="float: left; margin-right: 1em;">';
$form['addresses']['#suffix'] = '</div>';
}
$form['#attached']['drupalSettings']['addressTypeId'] = '#' . $type . '-address-select';
$form['close'] = [
'#type' => 'button',
'#value' => $this
->t('Close'),
'#attributes' => [
'id' => 'close-address-select',
],
];
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
}
}