You are here

protected function Products::productSelectForm in Ubercart 8.4

Form to choose a product to add to the order.

1 call to Products::productSelectForm()
Products::buildForm in uc_order/src/Plugin/Ubercart/OrderPane/Products.php
Form constructor.

File

uc_order/src/Plugin/Ubercart/OrderPane/Products.php, line 220

Class

Products
Manage the products an order contains.

Namespace

Drupal\uc_order\Plugin\Ubercart\OrderPane

Code

protected function productSelectForm($form, FormStateInterface $form_state, $order) {
  $options = $form_state
    ->get('product_select_options');
  $ajax = [
    'callback' => [
      $this,
      'ajaxCallback',
    ],
    'wrapper' => 'product-controls',
  ];
  $form['nid'] = [
    '#type' => 'select',
    '#options' => $options,
    '#size' => 7,
    '#ajax' => $ajax + [
      'event' => 'dblclick',
      'trigger_as' => [
        'name' => 'op',
        'value' => $this
          ->t('Select'),
      ],
    ],
  ];
  $form['product_search'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Search by name or model/SKU (* is the wildcard)'),
  ];
  $form['actions'] = [
    '#type' => 'actions',
  ];
  $form['actions']['select'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Select'),
    '#validate' => [
      [
        $this,
        'productSelectValidate',
      ],
    ],
    '#submit' => [
      [
        $this,
        'productSelectSubmit',
      ],
    ],
    '#ajax' => $ajax,
    '#weight' => 0,
  ];
  $form['actions']['search'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Search'),
    '#submit' => [
      [
        $this,
        'productSelectSearch',
      ],
    ],
    '#ajax' => $ajax,
    '#weight' => 1,
  ];
  $form['actions']['close'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Close'),
    '#submit' => [
      [
        $this,
        'productSelectClose',
      ],
    ],
    '#ajax' => $ajax,
    '#weight' => 2,
  ];
  return $form;
}