You are here

public function ComputedPhpFormatterPhp::settingsForm in Computed Field 8.2

Overrides ComputedStringFormatter::settingsForm

File

computed_field_php_formatter/src/Plugin/Field/FieldFormatter/ComputedPhpFormatterPhp.php, line 44
Contains \Drupal\Core\Field\Plugin\Field\FieldFormatter\ComputedPhpFormatterPhp.

Class

ComputedPhpFormatterPhp
Plugin implementation of the 'Free PHP' formatter for computed fields.

Namespace

Drupal\computed_field_php_formatter\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  return [
    'php_code' => [
      '#type' => 'textarea',
      '#title' => t('PHP Code'),
      '#default_value' => $this
        ->getSetting('php_code'),
      '#description' => t('Enter the PHP expression to format the value. The variables available to your code include:
<ul>
<li><code>$display_value</code>: the resulting value (to be set in this code),</li>
<li><code>$value</code>: the raw value to be formatted,</li>
<li><code>$value_escaped</code>: the sanitized value to be formatted,</li>
<li><code>$item</code>: the field item,</li>
<li><code>$delta</code>: current index of the field in case of multi-value computed fields (counting from 0).</li>
<li><code>$langcode</code>: The language code.</li>
</ul>'),
    ],
  ] + parent::settingsForm($form, $form_state);
}