Same name and namespace in other branches
  1. 1.1.x src/Plugin/Field/FieldFormatter/EntityReferenceFilteredLinkFormatter.php \Drupal\entity_ref_filtering_link\Plugin\Field\FieldFormatter\EntityReferenceFilteredLinkFormatter::settingsForm() 1 comment

File

src/Plugin/Field/FieldFormatter/EntityReferenceFilteredLinkFormatter.php, line 65

Class

EntityReferenceFilteredLinkFormatter
Plugin implementation of the 'entity_reference_filtered_link' formatter.

Namespace

Drupal\entity_ref_filtering_link\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
    $elements = [];
    $elements['view_url'] = [
        '#title' => $this->t('Url to the base page to apply the filter'),
        '#type' => 'textfield',
        '#default_value' => $this->getSetting('view_url'),
        '#required' => TRUE,
        '#description' => $this->t('If linking to a node or similar entity, it is strongly recommended to use the /node/### form to ensure that the link works even if the friendly url is changed.'),
    ];
    $elements['argument_name'] = [
        '#title' => $this->t('Argument Name'),
        '#type' => 'textfield',
        '#default_value' => $this->getArgumentName(),
        '#required' => TRUE,
        '#description' => $this->t('The argument identifier for within urls.'),
    ];
    $elements['mode'] = [
        '#title' => $this->t('Argument Mode'),
        '#required' => TRUE,
        '#type' => 'select',
        '#options' => [
            'id' => $this->t('Standard [$id]'),
            'id_multiple' => $this->t('Standard Multiple[] [$id]'),
            'id_multiple_d9' => $this->t('Standard Double Bracketed Multiple[$id] [$id]'),
            'autocomplete' => $this->t('Autocomplete [$label ($id)]'),
            'facet' => $this->t('Facet - ID [$id]'),
            'label' => $this->t('Facet - Label [$label]'),
            'label_no_facet' => $this->t('Label [$label]'),
        ],
        '#default_value' => $this->getSetting('mode'),
    ];
    $elements['skip_access_check'] = [
        '#title' => $this->t('Skip Access Check'),
        '#type' => 'checkbox',
        '#default_value' => $this->getSetting('skip_access_check'),
        '#description' => $this->t('If the view url is permission controlled but you still want to display it for users without access (such as to have them be able to click and be redirected to login page), enable this.'),
    ];
    $elements['disable'] = [
        '#title' => $this->t('Skip Linking'),
        '#type' => 'textfield',
        '#default_value' => $this->getSetting('disable'),
        '#description' => $this->t('Add comma seperated list of entity labels, if some references on this field should not have filter links generated for them.'),
    ];
    return $elements;
}