public function DeleteForm::buildForm in Domain Access 8
Build configuration form with metadata and values.
Overrides FormInterface::buildForm
File
- domain_config_ui/
src/ Form/ DeleteForm.php, line 27
Class
- DeleteForm
- Class DeleteForm.
Namespace
Drupal\domain_config_ui\FormCode
public function buildForm(array $form, FormStateInterface $form_state, $config_name = NULL) {
if (empty($config_name)) {
$url = Url::fromRoute('domain_config_ui.list');
return new RedirectResponse($url
->toString());
}
$elements = DomainConfigUIController::deriveElements($config_name);
$config = \Drupal::configFactory()
->get($config_name)
->getRawData();
$form['help'] = [
'#type' => 'item',
'#title' => Html::escape($config_name),
'#markup' => $this
->t('Are you sure you want to delete the configuration
override: %config_name?', [
'%config_name' => $config_name,
]),
'#prefix' => '<p>',
'#suffix' => '</p>',
];
if ($elements['language'] == $this
->t('all')
->render()) {
$language = $this
->t('all languages');
}
else {
$language = $this
->t('the @language language.', [
'@language' => $elements['language'],
]);
}
$form['more_help'] = [
'#markup' => $this
->t('This configuration is for the %domain domain and
applies to %language.', [
'%domain' => $elements['domain'],
'%language' => $language,
]),
'#prefix' => '<p>',
'#suffix' => '</p>',
];
$form['review'] = [
'#type' => 'details',
'#title' => $this
->t('Review settings'),
'#open' => FALSE,
];
$form['review']['text'] = [
'#markup' => DomainConfigUIController::printArray($config),
];
$form['config_name'] = [
'#type' => 'value',
'#value' => $config_name,
];
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Delete configuration'),
'#button_type' => 'primary',
];
$form['actions']['cancel'] = [
'#type' => 'link',
'#title' => $this
->t('Cancel'),
'#url' => new Url('domain_config_ui.list'),
'#attributes' => [
'class' => [
'button',
],
],
];
return $form;
}