public function ReferenceSettings::buildForm in Bibliography & Citation 8
Same name and namespace in other branches
- 2.0.x modules/bibcite_entity/src/Form/ReferenceSettings.php \Drupal\bibcite_entity\Form\ReferenceSettings::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- modules/
bibcite_entity/ src/ Form/ ReferenceSettings.php, line 30
Class
- ReferenceSettings
- Common Reference settings.
Namespace
Drupal\bibcite_entity\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config_modes = $this->configFactory
->listAll('core.entity_view_mode.bibcite_reference');
$modes = [
'default' => $this
->t('Default'),
];
foreach ($config_modes as $config_name) {
$mode = $this->configFactory
->getEditable($config_name);
// Get substring 'view_mode_name' from 'bibcite_reference.view_mode_name'
// id string. String 'bibcite_reference.' contains 18 symbols.
$name = substr($mode
->get('id'), 18);
$modes[$name] = $this
->t($mode
->get('label'));
}
$config = $this
->config('bibcite_entity.reference.settings');
$form['view_mode'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Reference page view mode'),
'#tree' => TRUE,
];
$form['view_mode']['reference_page_view_mode'] = [
'#type' => 'select',
'#options' => $modes,
'#title' => $this
->t('Reference page view mode'),
'#description' => $this
->t('View mode which is used for rendering reference entities on their own pages.'),
'#default_value' => $config
->get('display_override.reference_page_view_mode'),
];
$form['ui_override'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Interface override'),
'#tree' => TRUE,
];
$form['ui_override']['enable_form_override'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Override entity forms'),
'#description' => $this
->t("Regroup all base fields of Reference entity to vertical tabs. You can use it if you don't want to configure form display view."),
'#default_value' => $config
->get('ui_override.enable_form_override'),
];
$form['citekey'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Citation key'),
'#tree' => TRUE,
];
$form['citekey']['citekey_pattern'] = [
'#type' => 'textfield',
'#title' => $this
->t('Citation key pattern'),
'#description' => $this
->t('Pattern for citation key automatic generation if value is not set.'),
'#maxlength' => 255,
'#default_value' => $config
->get('citekey.pattern'),
];
$form['citekey']['token_help'] = [
'#theme' => 'token_tree_link',
'#token_types' => [
'bibcite_reference',
],
'#global_types' => TRUE,
];
return parent::buildForm($form, $form_state);
}