ForwardWidget.php in Forward 4.x
File
src/Plugin/Field/FieldWidget/ForwardWidget.php
View source
<?php
namespace Drupal\forward\Plugin\Field\FieldWidget;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Form\FormStateInterface;
class ForwardWidget extends WidgetBase {
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$display = $items[$delta]
->get('display')
->getValue();
$options = [
TRUE => $this
->t('Display the Forward link'),
FALSE => $this
->t('Hide the Forward link'),
];
$element['display'] = [
'#title' => $this
->t('Display'),
'#type' => 'radios',
'#options' => $options,
'#default_value' => $display ?? TRUE,
];
$element['#type'] = 'details';
$element['#group'] = 'advanced';
return $element;
}
}