Currently, TemplateInheritance#renderTwigSurrogateIfExists() only renders a surrogate if the object is a Template instance. We're doing this so we can reliably build the right context for the Twig version (injecting $arrData making the methods available and so on…).
We're also having widgets, though that are using the TemplateInheritance.
abstract class Widget extends Controller
{
use TemplateInheritance;
// …
}
This for instance means it's currently not possible to overwrite form_textfield with form_textfield.html.twig.
We can of course allow other classes as well in the check but we must then also make sure we're building the right context e.g. with a new ContextHelper::fromContaoWidget() method.
Affected version(s)
Contao 4.12
Description
Currently,
TemplateInheritance#renderTwigSurrogateIfExists()
only renders a surrogate if the object is aTemplate
instance. We're doing this so we can reliably build the right context for the Twig version (injecting$arrData
making the methods available and so on…).https://github.com/contao/contao/blob/82286f4c90e3bf2bc7857ddca6db7823fe271738/core-bundle/src/Resources/contao/library/Contao/TemplateInheritance.php#L365-L368
We're also having widgets, though that are using the
TemplateInheritance
.This for instance means it's currently not possible to overwrite
form_textfield
withform_textfield.html.twig
.We can of course allow other classes as well in the check but we must then also make sure we're building the right context e.g. with a new
ContextHelper::fromContaoWidget()
method.