public function FormEntryTypeBase::buildConfigurationForm in Flag 8.4
Provides a form array for the action link plugin's settings form.
Derived classes will want to override this method.
Parameters
array $form: The form array.
FormStateInterface $form_state: The form state.
Return value
array The modified form array.
Overrides ActionLinkTypeBase::buildConfigurationForm
1 call to FormEntryTypeBase::buildConfigurationForm()
- FieldEntry::buildConfigurationForm in src/
Plugin/ ActionLink/ FieldEntry.php - Provides a form array for the action link plugin's settings form.
1 method overrides FormEntryTypeBase::buildConfigurationForm()
- FieldEntry::buildConfigurationForm in src/
Plugin/ ActionLink/ FieldEntry.php - Provides a form array for the action link plugin's settings form.
File
- src/
Plugin/ ActionLink/ FormEntryTypeBase.php, line 36
Class
- FormEntryTypeBase
- Base class for link types using form entry.
Namespace
Drupal\flag\Plugin\ActionLinkCode
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$plugin_id = $this
->getPluginId();
$plugin_description = $this->pluginDefinition['label'];
$form['display']['settings']['link_options_' . $plugin_id] = [
'#type' => 'details',
'#open' => TRUE,
'#title' => $this
->t('Options for the "@label" link type', [
'@label' => $plugin_description,
]),
// Any "link type" provider module must put its settings fields inside
// a fieldset whose HTML ID is link-options-LINKTYPE, where LINKTYPE is
// the machine-name of the link type. This is necessary for the
// radiobutton's JavaScript dependency feature to work.
'#id' => 'link-options-confirm',
];
$form['display']['settings']['link_options_' . $plugin_id]['flag_confirmation'] = [
'#type' => 'textfield',
'#title' => $this
->t('Flag confirmation message'),
'#default_value' => $this
->getFlagQuestion(),
'#description' => $this
->t('Message displayed if the user has clicked the "flag this" link and confirmation is required. Usually presented in the form of a question such as, "Are you sure you want to flag this content?"'),
// This will get changed to a state by flag_link_type_options_states().
'#required' => TRUE,
];
$form['display']['settings']['link_options_' . $plugin_id]['unflag_confirmation'] = [
'#type' => 'textfield',
'#title' => $this
->t('Unflag confirmation message'),
'#default_value' => $this
->getUnflagQuestion(),
'#description' => $this
->t('Message displayed if the user has clicked the "unflag this" link and confirmation is required. Usually presented in the form of a question such as, "Are you sure you want to unflag this content?"'),
// This will get changed to a state by flag_link_type_options_states().
'#required' => TRUE,
];
$form['display']['settings']['link_options_' . $plugin_id]['flag_create_button'] = [
'#type' => 'textfield',
'#title' => $this
->t('Create flagging button text'),
'#default_value' => $this->configuration['flag_create_button'],
'#description' => $this
->t('The text for the submit button when creating a flagging.'),
// This will get changed to a state by flag_link_type_options_states().
'#required' => TRUE,
];
$form['display']['settings']['link_options_' . $plugin_id]['flag_delete_button'] = [
'#type' => 'textfield',
'#title' => $this
->t('Delete flagging button text'),
'#default_value' => $this->configuration['flag_delete_button'],
'#description' => $this
->t('The text for the submit button when deleting a flagging.'),
// This will get changed to a state by flag_link_type_options_states().
'#required' => TRUE,
];
$form['display']['settings']['link_options_' . $plugin_id]['form_behavior'] = [
'#type' => 'radios',
'#title' => $this
->t('Form behavior'),
'#options' => [
'default' => $this
->t('New page'),
'dialog' => $this
->t('Dialog'),
'modal' => $this
->t('Modal dialog'),
],
'#description' => $this
->t('If an option other than <em>new page</em> is selected, the form will open via AJAX on the same page.'),
'#default_value' => $this->configuration['form_behavior'],
];
return $form;
}