3 namespace Drupal\{{ machine_name }}\Plugin\views\field;
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\views\Plugin\views\field\FieldPluginBase;
7 use Drupal\views\ResultRow;
10 * Provides {{ plugin_label }} field handler.
12 * @ViewsField("{{ plugin_id }}")
14 class {{ class }} extends FieldPluginBase {
19 protected function defineOptions() {
20 $options = parent::defineOptions();
21 $options['prefix'] = ['default' => ''];
22 $options['suffix'] = ['default' => ''];
29 public function buildOptionsForm(&$form, FormStateInterface $form_state) {
30 parent::buildOptionsForm($form, $form_state);
33 '#type' => 'textfield',
34 '#title' => $this->t('Prefix'),
35 '#default_value' => $this->options['prefix'],
39 '#type' => 'textfield',
40 '#title' => $this->t('Suffix'),
41 '#default_value' => $this->options['suffix'],
48 public function render(ResultRow $values) {
49 return $this->options['prefix'] . parent::render($values) . $this->options['suffix'];