/** * {@inheritdoc} */ 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' => array(0 => 0), ]; $form['access']['access_uid'] = [ '#type' => 'checkbox', '#title' => t('Users may flag themselves'), '#description' => t('Disabling this option may be useful when setting up a "friend" flag, when a user flagging themselves does not make sense.'), '#default_value' => $this->getAccessUidSetting(), ]; $form['display']['show_on_profile'] = [ '#type' => 'checkbox', '#title' => t('Display link on user profile page'), '#description' => t('Show the link formatted as a user profile element.'), '#default_value' => $this->showOnProfile(), // Put this above 'show on entity'. '#weight' => -1, ]; return $form; }
/** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form = parent::buildConfigurationForm($form, $form_state); /* Options form extras for node flags. */ $form['access']['access_author'] = [ '#type' => 'radios', '#title' => t('Flag access by content authorship'), '#options' => [ '' => t('No additional restrictions'), 'own' => t('Users may only flag content they own'), 'others' => t('Users may only flag content of others'), ], '#default_value' => $this->getAccessAuthorSetting(), '#description' => t("Restrict access to this flag based on the user's ownership of the content. Users must also have access to the flag through the role settings."), ]; // Support for i18n flagging requires Translation helpers module. $form['i18n'] = [ '#type' => 'radios', '#title' => t('Internationalization'), '#options' => [ '1' => t('Flag translations of content as a group'), '0' => t('Flag each translation of content separately'), ], '#default_value' => $this->getInternationalizationSetting(), '#description' => t('Flagging translations as a group effectively allows users to flag the original piece of content regardless of the translation they are viewing. Changing this setting will <strong>not</strong> update content that has been flagged already.'), '#access' => \Drupal::moduleHandler()->moduleExists('translation_helpers'), '#weight' => 5, ]; return $form; }
/** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form = parent::buildConfigurationForm($form, $form_state); /* Options form extras for comment flags. */ $form['access']['access_author'] = [ '#type' => 'radios', '#title' => t('Flag access by content authorship'), '#options' => [ '' => t('No additional restrictions'), 'comment_own' => t('Users may only flag own comments'), 'comment_others' => t('Users may only flag comments by others'), 'node_own' => t('Users may only flag comments of nodes they own'), 'node_others' => t('Users may only flag comments of nodes by others'), ], '#default_value' => $this->configuration['access_author'], '#description' => t("Restrict access to this flag based on the user's ownership of the content. Users must also have access to the flag through the role settings."), ]; return $form; }