public function WebformVariantApplyForm::getConfirmInput in Webform 8.5
Same name and namespace in other branches
- 6.x src/Form/WebformVariantApplyForm.php \Drupal\webform\Form\WebformVariantApplyForm::getConfirmInput()
Returns confirm input to display.
Return value
array A renderable array containing confirm input.
Overrides WebformDeleteFormBase::getConfirmInput
File
- src/
Form/ WebformVariantApplyForm.php, line 136
Class
- WebformVariantApplyForm
- Form for apply a webform variant.
Namespace
Drupal\webform\FormCode
public function getConfirmInput() {
$webform = $this->webform;
$build = [];
if ($this->hasMultipleVariants || empty($this->webformVariant)) {
$build['variants'] = [
'#tree' => TRUE,
];
$element_keys = $webform
->getElementsVariant();
foreach ($element_keys as $element_key) {
$element = $webform
->getElement($element_key);
$variants = $webform
->getVariants(NULL, NULL, $element_key);
if (!$variants
->count()) {
continue;
}
$variant_options = [];
foreach ($variants as $variant) {
$variant_options[$variant
->getVariantId()] = $variant
->label();
}
$build['variants'][$element_key] = [
'#type' => 'select',
'#title' => WebformElementHelper::getAdminTitle($element),
'#options' => $variant_options,
'#empty_option' => $this
->t('- None -'),
'#default_value' => $this->webformVariant ? $this->webformVariant
->getVariantId() : '',
];
}
}
$build['delete'] = [
'#type' => 'radios',
'#title' => $this->hasMultipleVariants ? $this
->t('After selected variants are applied…') : $this
->t('After this variant is applied…'),
'#options' => [
'selected' => $this->hasMultipleVariants ? $this
->t('Delete the selected variants') : $this
->t('Delete this variant'),
'all' => $this
->t('Delete all variants'),
'none' => $this
->t('Do not delete any variants'),
],
'#required' => TRUE,
];
return $build;
}