You are here

public function UserConsentItem::fieldSettingsForm in General Data Protection Regulation 8

Same name and namespace in other branches
  1. 8.2 modules/gdpr_consent/src/Plugin/Field/FieldType/UserConsentItem.php \Drupal\gdpr_consent\Plugin\Field\FieldType\UserConsentItem::fieldSettingsForm()
  2. 3.0.x modules/gdpr_consent/src/Plugin/Field/FieldType/UserConsentItem.php \Drupal\gdpr_consent\Plugin\Field\FieldType\UserConsentItem::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

File

modules/gdpr_consent/src/Plugin/Field/FieldType/UserConsentItem.php, line 113

Class

UserConsentItem
Plugin implementation of the 'gdpr_user_consent' field type.

Namespace

Drupal\gdpr_consent\Plugin\Field\FieldType

Code

public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
  $agreement_ids = \Drupal::entityQuery('gdpr_consent_agreement')
    ->condition('status', 1)
    ->sort('title')
    ->execute();
  $agreements = ConsentAgreement::loadMultiple($agreement_ids);
  $element = [];
  $element['target_id'] = [
    '#type' => 'select',
    '#title' => 'Agreement',
    '#required' => TRUE,
    '#options' => [
      '' => 'Please select',
    ] + $agreements,
    '#default_value' => $this
      ->getSetting('target_id'),
  ];
  return $element;
}