You are here

public function ComputedStringItemBase::fieldSettingsForm in Computed Field 8.2

Same name and namespace in other branches
  1. 3.x src/Plugin/Field/FieldType/ComputedStringItemBase.php \Drupal\computed_field\Plugin\Field\FieldType\ComputedStringItemBase::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 FieldItemBase::fieldSettingsForm

2 calls to ComputedStringItemBase::fieldSettingsForm()
ComputedStringItem::fieldSettingsForm in src/Plugin/Field/FieldType/ComputedStringItem.php
Returns a form for the field-level settings.
ComputedStringLongItem::fieldSettingsForm in src/Plugin/Field/FieldType/ComputedStringLongItem.php
Returns a form for the field-level settings.
2 methods override ComputedStringItemBase::fieldSettingsForm()
ComputedStringItem::fieldSettingsForm in src/Plugin/Field/FieldType/ComputedStringItem.php
Returns a form for the field-level settings.
ComputedStringLongItem::fieldSettingsForm in src/Plugin/Field/FieldType/ComputedStringLongItem.php
Returns a form for the field-level settings.

File

src/Plugin/Field/FieldType/ComputedStringItemBase.php, line 28

Class

ComputedStringItemBase
Plugin base of the string field type.

Namespace

Drupal\computed_field\Plugin\Field\FieldType

Code

public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
  $element = $this
    ->getFieldSettingsFormBase($form, $form_state);
  $element['code']['#title'] = $this
    ->t('Code (PHP) to compute the <em>text</em> value');
  $element['code']['#description'] .= t('
<p>
  Here\'s a simple example using the <code>$entity</code>-array which sets the computed field\'s value to the concatenation of fields (<code>field_a</code> and <code>field_b</code>) in an entity:
  <ul>
    <li><code>$value = $entity->field_a->value . $entity->field_b->value;</code></li>
  </ul>
</p>
<p>
  An alternative example using the <code>$fields</code>-array:
  <ul>
    <li><code>$value = $fields[\'field_a\'][0][\'value\'] . $fields[\'field_b\'][0][\'value\'];</code></li>
  </ul>
</p>
<p>
  For information on working with multi-valued fields, read the documentation page at <a href="https://www.drupal.org/node/249907">Working with multiple values</a>.
</p>
    ');
  return $element;
}