function RenderElementBase::createChild
Creates a render object and attaches it to the current render object.
@template T of \Drupal\Core\Render\Element\ElementInterface
Parameters
int|string $name: The name of the child. Can also be an integer.
class-string<T> $class: The class of the render object.
array $configuration: An array of configuration relevant to the render object.
bool $copyProperties: Copy properties (but not children) from the parent. This is useful for widgets for example.
Return value
T The child render object.
Overrides ElementInterface::createChild
File
-
core/
lib/ Drupal/ Core/ Render/ Element/ RenderElementBase.php, line 678
Class
- RenderElementBase
- Provides a base class for render element plugins.
Namespace
Drupal\Core\Render\ElementCode
public function createChild(int|string $name, string $class, array $configuration = [], bool $copyProperties = FALSE) : ElementInterface {
$childObject = $this->elementInfoManager()
->fromClass($class, $configuration);
$childObject = $this->addChild($name, $childObject);
if ($copyProperties) {
$childObject->storage += array_filter($this->storage, Element::property(...), \ARRAY_FILTER_USE_KEY);
}
return $childObject;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.