You are here

public function UserFlagType::buildConfigurationForm in Flag 8.4

Provides a form for this action link plugin settings.

The form provided by this method is displayed by the FlagAddForm when creating or editing the Flag. Derived classes should override this.

Parameters

array $form: The form array.

FormStateInterface $form_state: The form state.

Return value

array The form array

Overrides EntityFlagType::buildConfigurationForm

See also

\Drupal\flag\Form\FlagAddForm

File

src/Plugin/Flag/UserFlagType.php, line 37

Class

UserFlagType
Provides a flag type for user entities.

Namespace

Drupal\flag\Plugin\Flag

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildConfigurationForm($form, $form_state);

  /* Options form extras for user flags */
  $form['access']['bundles'] = [
    // A user flag doesn't support node types.
    // TODO: Maybe support roles instead of node types.
    '#type' => 'value',
    '#value' => [
      0 => 0,
    ],
  ];
  $form['display']['show_on_profile'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Display link on user profile page'),
    '#description' => $this
      ->t('Show the link formatted as a user profile element.'),
    '#default_value' => $this
      ->showOnProfile(),
    // Put this above 'show on entity'.
    '#weight' => -1,
  ];
  return $form;
}