public function IngredientItem::fieldSettingsForm in Recipe 8.2
@todo Migrate the default_unit setting to the defaultValuesForm().
Overrides EntityReferenceItem::fieldSettingsForm
File
- modules/
ingredient/ src/ Plugin/ Field/ FieldType/ IngredientItem.php, line 111
Class
- IngredientItem
- Plugin implementation of the 'ingredient' field type.
Namespace
Drupal\ingredient\Plugin\Field\FieldTypeCode
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
$element = [];
$element['unit_sets'] = [
'#type' => 'checkboxes',
'#title' => $this
->t('Enable sets of units'),
'#default_value' => $this
->getSetting('unit_sets'),
'#options' => \Drupal::service('ingredient.unit')
->getUnitSetOptions(),
'#description' => $this
->t('Units in enabled sets will appear in the field widget. If no sets are selected then all units will appear by default.'),
'#ajax' => [
'callback' => [
$this,
'setChangeAjaxCallback',
],
'wrapper' => 'default-unit-wrapper',
],
];
$element['default_unit'] = [
'#type' => 'select',
'#title' => $this
->t('Default unit type for ingredients'),
'#default_value' => $this
->getSetting('default_unit'),
'#options' => [],
'#process' => [
[
$this,
'processDefaultUnit',
],
],
'#prefix' => '<div id="default-unit-wrapper">',
'#suffix' => '</div>',
];
return $element;
}