public function AddressPaneBase::buildForm in Ubercart 8.4
Form constructor.
Parameters
\Drupal\uc_order\OrderInterface $order: The order that is being viewed.
array $form: An array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides EditableOrderPanePluginInterface::buildForm
2 calls to AddressPaneBase::buildForm()
- BillTo::buildForm in uc_order/
src/ Plugin/ Ubercart/ OrderPane/ BillTo.php - Form constructor.
- ShipTo::buildForm in uc_order/
src/ Plugin/ Ubercart/ OrderPane/ ShipTo.php - Form constructor.
2 methods override AddressPaneBase::buildForm()
- BillTo::buildForm in uc_order/
src/ Plugin/ Ubercart/ OrderPane/ BillTo.php - Form constructor.
- ShipTo::buildForm in uc_order/
src/ Plugin/ Ubercart/ OrderPane/ ShipTo.php - Form constructor.
File
- uc_order/
src/ Plugin/ Ubercart/ OrderPane/ AddressPaneBase.php, line 33
Class
- AddressPaneBase
- Provides a generic address pane that can be extended as required.
Namespace
Drupal\uc_order\Plugin\Ubercart\OrderPaneCode
public function buildForm(OrderInterface $order, array $form, FormStateInterface $form_state) {
$pane = $this->pluginDefinition['id'];
// Need to pass along uid, address pane selector, and pane id
// for use in the JavaScript.
$form['#attached']['drupalSettings'] = [
'uid' => $order
->getOwnerId(),
'paneId' => '#' . $pane . '-address-select',
'addressType' => $pane,
];
$form['address-book-image'] = [
'#theme' => 'image',
'#uri' => base_path() . drupal_get_path('module', 'uc_store') . '/images/address_book.gif',
'#title' => $this
->t('Select from address book.'),
'#alt' => $this
->t('Select from address book.'),
'#attributes' => [
'class' => 'load-address-select',
],
'#prefix' => '<div class="order-pane-icons">',
];
$form['copy-address-image'] = [
'#theme' => 'image',
'#uri' => base_path() . drupal_get_path('module', 'uc_store') . '/images/copy.gif',
// Need to set #title, #alt, and #attributes in derived class.
'#suffix' => '</div>',
];
// An empty <div> to put our address book select into.
// @todo This can be done with core Ajax.
$form['icons'] = [
'#type' => 'markup',
'#markup' => '<div id="' . $pane . '-address-select"></div>',
];
$form['address'] = [
'#type' => 'uc_address',
'#parents' => [
$pane,
],
'#default_value' => $order
->getAddress($pane),
'#required' => FALSE,
];
return $form;
}