protected function YamlFormEntitySettingsForm::appendDefaultValueToElementDescriptions in YAML Form 8
Append default value to an element's description.
Parameters
array $form: An associative array containing the structure of the form.
array $default_settings: An associative array container default yamlform settings.
1 call to YamlFormEntitySettingsForm::appendDefaultValueToElementDescriptions()
- YamlFormEntitySettingsForm::form in src/
YamlFormEntitySettingsForm.php - Gets the actual form array to be built.
File
- src/
YamlFormEntitySettingsForm.php, line 910
Class
- YamlFormEntitySettingsForm
- Provides a form to manage settings.
Namespace
Drupal\yamlformCode
protected function appendDefaultValueToElementDescriptions(array &$form, array $default_settings) {
foreach ($form as $key => &$element) {
// Skip if not a FAPI element.
if (Element::property($key) || !is_array($element)) {
continue;
}
if (isset($element['#type']) && !empty($default_settings["default_{$key}"]) && empty($element['#disabled'])) {
if (!isset($element['#description'])) {
$element['#description'] = '';
}
$element['#description'] .= $element['#description'] ? '<br/>' : '';
$element['#description'] .= $this
->t('Defaults to: %value', [
'%value' => $default_settings["default_{$key}"],
]);
}
$this
->appendDefaultValueToElementDescriptions($element, $default_settings);
}
}