Trying to build out a custom form field type in Symfony, but the widget block is not rendering. I set up a widget for a text field type in the same file, and that rendered properly. What would cause my widget to not find it's template block?
MediaGalleryType.php
class MediaGalleryType extends AbstractType
{
public function getParent()
{
return TextType::class;
}
}
mediagallery.html.twig
{% block mediagallery_widget %}
HTML Goes here
{% endblock %}
{% block text_widget %}
This replaces all text type fields
{% endblock %}
twig.yaml
twig:
form_themes:
- 'mediagallery.html.twig'
After some more digging around in sourcecode for Symfony form types, I found a method I can extend that returns the block prefix.
public function getBlockPrefix()
{
return 'mediagallery';
}