protected function WebformElementBase::setElementDefaultCallback in Webform 8.5
Same name and namespace in other branches
- 6.x src/Plugin/WebformElementBase.php \Drupal\webform\Plugin\WebformElementBase::setElementDefaultCallback()
Set element's default callback.
This makes sure that an element's default callback is not clobbered by any additional callbacks.
Parameters
array $element: A render element.
string $callback_name: A render element's callback.
5 calls to WebformElementBase::setElementDefaultCallback()
- OptionsBase::prepare in src/
Plugin/ WebformElement/ OptionsBase.php - Prepare an element to be rendered within a webform.
- TextFormat::prepare in src/
Plugin/ WebformElement/ TextFormat.php - Prepare an element to be rendered within a webform.
- WebformElementBase::finalize in src/
Plugin/ WebformElementBase.php - Finalize an element to be rendered within a webform.
- WebformElementBase::prepare in src/
Plugin/ WebformElementBase.php - Prepare an element to be rendered within a webform.
- WebformManagedFileBase::prepare in src/
Plugin/ WebformElement/ WebformManagedFileBase.php - Prepare an element to be rendered within a webform.
File
- src/
Plugin/ WebformElementBase.php, line 448
Class
- WebformElementBase
- Provides a base class for a webform element.
Namespace
Drupal\webform\PluginCode
protected function setElementDefaultCallback(array &$element, $callback_name) {
$callback_name = $callback_name[0] !== '#' ? '#' . $callback_name : $callback_name;
$callback_value = $this
->getElementInfoDefaultProperty($element, $callback_name) ?: [];
if (!empty($element[$callback_name])) {
$element[$callback_name] = array_merge($callback_value, $element[$callback_name]);
}
else {
$element[$callback_name] = $callback_value;
}
}