public function PadoAddToCartFormatter::settingsForm in Commerce Product Add-on 8
Returns a form to configure settings for the formatter.
Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the formatter. The field_ui module takes care of handling submitted form values.
Parameters
array $form: The form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form elements for the formatter settings.
Overrides AddToCartFormatter::settingsForm
File
- src/
Plugin/ Field/ FieldFormatter/ PadoAddToCartFormatter.php, line 36
Class
- PadoAddToCartFormatter
- Plugin implementation of the 'commerce_pado_add_to_cart' formatter.
Namespace
Drupal\commerce_pado\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$form = parent::settingsForm($form, $form_state);
$form['multiple'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Multiple.'),
'#description' => $this
->t('Customer should be able to select multiple add-ons.'),
'#default_value' => $this
->getSetting('multiple'),
];
$form['add_on_field'] = [
'#type' => 'select',
'#title' => $this
->t('The product entity reference field to select add-ons from.'),
'#description' => $this
->t('All the variations belonging to the selected products in the field will be offered as add-ons.'),
'#default_value' => $this
->getSetting('add_on_field'),
'#options' => $this
->getReferenceFieldOptions($this->fieldDefinition),
'#required' => TRUE,
];
return $form;
}