public function ComputedFieldItemTrait::fieldSettingsForm in Computed Field 3.x
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldType/ComputedFieldItemTrait.php \Drupal\computed_field\Plugin\Field\FieldType\ComputedFieldItemTrait::fieldSettingsForm()
Default field settings form.
2 calls to ComputedFieldItemTrait::fieldSettingsForm()
- ComputedFieldItemBase::fieldSettingsForm in src/
Plugin/ Field/ FieldType/ ComputedFieldItemBase.php - Returns a form for the field-level settings.
- ComputedStringItemBase::fieldSettingsForm in src/
Plugin/ Field/ FieldType/ ComputedStringItemBase.php - Returns a form for the field-level settings.
File
- src/
Plugin/ Field/ FieldType/ ComputedFieldItemTrait.php, line 66
Class
- ComputedFieldItemTrait
- Common methods for Computed Field FieldType plugins.
Namespace
Drupal\computed_field\Plugin\Field\FieldTypeCode
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
$field_name = $this->definition
->getFieldDefinition()
->getName();
$service = \Drupal::service('computed_field.helpers');
$element = [];
$element['hook_info'] = [
'#markup' => t('
<p>The hook implementation function signature should be
<strong>%function($entity_type_manager, $entity, $fields, $delta)</strong>,
and the desired value should be returned.</em>
</p>
<p>The variables available to your code include:</p>
<ul>
<li><code>$entity_type_manager</code>: The entity type manager.</li>
<li><code>$entity</code>: The entity the field belongs to.</li>
<li><code>$fields</code>: The list of fields available in this entity.</li>
<li><code>$delta</code>: Current index of the field in case of multi-value computed fields (counting from 0).</li>
<li><code>$value</code>: The resulting value to be set above, or returned in your hook implementation).</li>
</ul>
', [
'%function' => $service
->getComputeFunctionName($field_name),
]),
];
return $element;
}