public function WishlistItemDetailsForm::form in Commerce Wishlist 8.3
Gets the actual form array to be built.
Overrides EntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- src/
Form/ WishlistItemDetailsForm.php, line 27
Class
- WishlistItemDetailsForm
- Provides the wishlist details form.
Namespace
Drupal\commerce_wishlist\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
/** @var \Drupal\commerce_wishlist\Entity\WishlistItemInterface $wishlist_item */
$wishlist_item = $this->entity;
$form['#tree'] = TRUE;
$form['#attached']['library'][] = 'core/drupal.dialog.ajax';
// Workaround for core bug #2897377.
$form['#id'] = Html::getId($form_state
->getBuildInfo()['form_id']);
$form['comment'] = [
'#type' => 'textarea',
'#title' => $this
->t('Comment'),
'#rows' => 5,
'#default_value' => $wishlist_item
->getComment(),
];
$form['quantity'] = [
'#type' => 'commerce_number',
'#title' => $this
->t('Quantity'),
'#required' => TRUE,
'#default_value' => $wishlist_item
->getQuantity(),
];
return $form;
}