public function WebformEntityReferenceEntityFormatter::settingsForm in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/Field/FieldFormatter/WebformEntityReferenceEntityFormatter.php \Drupal\webform\Plugin\Field\FieldFormatter\WebformEntityReferenceEntityFormatter::settingsForm()
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 FormatterBase::settingsForm
File
- src/
Plugin/ Field/ FieldFormatter/ WebformEntityReferenceEntityFormatter.php, line 88
Class
- WebformEntityReferenceEntityFormatter
- Plugin implementation of the 'Webform rendered entity' formatter.
Namespace
Drupal\webform\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
if ($this->fieldDefinition
->getTargetEntityTypeId() === 'paragraph') {
$title = $this
->t("Use this paragraph field's main entity as the webform submission's source entity.");
$description = $this
->t("If unchecked, the current page's entity will be used as the webform submission's source entity.");
}
else {
$entity_type_definition = $this->entityTypeManager
->getDefinition($this->fieldDefinition
->getTargetEntityTypeId());
$title = $this
->t("Use this field's %entity_type entity as the webform submission's source entity.", [
'%entity_type' => $entity_type_definition
->getLabel(),
]);
$description = $this
->t("If unchecked, the current page's entity will be used as the webform submission's source entity. For example, if this webform was displayed on a node's page, the current node would be used as the webform submission's source entity.", [
'%entity_type' => $entity_type_definition
->getLabel(),
]);
}
$form = parent::settingsForm($form, $form_state);
$form['source_entity'] = [
'#title' => $title,
'#description' => $description,
'#type' => 'checkbox',
'#return_type' => TRUE,
'#default_value' => $this
->getSetting('source_entity'),
];
return $form;
}