public function ShippingQuoteMethodListBuilder::buildForm in Ubercart 8.4
Form constructor.
Parameters
array $form: An associative 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 DraggableListBuilder::buildForm
File
- shipping/
uc_quote/ src/ ShippingQuoteMethodListBuilder.php, line 91
Class
- ShippingQuoteMethodListBuilder
- Provides a listing of shipping quote method entities.
Namespace
Drupal\uc_quoteCode
public function buildForm(array $form, FormStateInterface $form_state) {
$options = array_map(function ($definition) {
return $definition['admin_label'];
}, $this->shippingQuotePluginManager
->getDefinitions());
uasort($options, 'strnatcasecmp');
$form['add'] = [
'#type' => 'details',
'#title' => $this
->t('Add shipping method'),
'#open' => TRUE,
'#attributes' => [
'class' => [
'container-inline',
],
],
];
$form['add']['plugin'] = [
'#type' => 'select',
'#title' => $this
->t('Type'),
'#empty_option' => $this
->t('- Choose -'),
'#options' => $options,
];
$form['add']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Add shipping method'),
'#validate' => [
'::validateAddMethod',
],
'#submit' => [
'::submitAddMethod',
],
'#limit_validation_errors' => [
[
'plugin',
],
],
];
$form = parent::buildForm($form, $form_state);
$form[$this->entitiesKey]['#empty'] = $this
->t('No shipping methods have been configured yet.');
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Save configuration'),
'#button_type' => 'primary',
];
return $form;
}