public function PriceModifiedItem::fieldSettingsForm in Price 8
Same name and namespace in other branches
- 3.x src/Plugin/Field/FieldType/PriceModifiedItem.php \Drupal\price\Plugin\Field\FieldType\PriceModifiedItem::fieldSettingsForm()
- 3.0.x src/Plugin/Field/FieldType/PriceModifiedItem.php \Drupal\price\Plugin\Field\FieldType\PriceModifiedItem::fieldSettingsForm()
Returns a form for the field-level settings.
Invoked from \Drupal\field_ui\Form\FieldConfigEditForm to allow administrators to configure field-level settings.
Parameters
array $form: The form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface $form_state: The form state of the (entire) configuration form.
Return value
array The form definition for the field settings.
Overrides PriceItem::fieldSettingsForm
File
- src/
Plugin/ Field/ FieldType/ PriceModifiedItem.php, line 65
Class
- PriceModifiedItem
- Plugin implementation of the 'modified price' field type.
Namespace
Drupal\price\Plugin\Field\FieldTypeCode
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
$element = parent::fieldSettingsForm($form, $form_state);
$modifiers = \Drupal::entityTypeManager()
->getStorage('price_modifier')
->loadMultiple();
$modifier_codes = array_keys($modifiers);
$modifier_options = [];
foreach ($modifier_codes as $modifier_code) {
$modifier_options[$modifier_code] = $modifiers[$modifier_code]
->label();
}
$element['available_modifiers'] = [
'#type' => count($modifier_codes) < 10 ? 'checkboxes' : 'select',
'#title' => $this
->t('Available modifiers'),
'#description' => $this
->t('If no modifiers are selected, all modifiers will be available.'),
'#options' => $modifier_options,
'#default_value' => $this
->getSetting('available_modifiers'),
'#multiple' => TRUE,
'#size' => 5,
];
return $element;
}