symfony-cmf / core-bundle

Provides some basic helpers for rendering content documents
https://cmf.symfony.com
25 stars 33 forks source link

[BUG] Unable to find template "CmfCoreBundle:Form:checkbox_url_label_form_type.html.twig" #263

Closed esserj closed 5 years ago

esserj commented 5 years ago

Environment

Any

Symfony packages

$ composer show --latest 'symfony/*'

symfony/asset v4.1.8 v4.1.8 Symfony Asset Component symfony/browser-kit v4.1.8 v4.1.8 Symfony BrowserKit Component symfony/cache v4.1.8 v4.1.8 Symfony Cache component with PSR-6, PSR-16, and tags symfony/class-loader v3.4.19 v3.4.19 Symfony ClassLoader Component symfony/config v4.1.8 v4.1.8 Symfony Config Component symfony/console v4.1.8 v4.1.8 Symfony Console Component symfony/css-selector v3.4.19 v4.1.8 Symfony CssSelector Component symfony/debug v4.1.8 v4.1.8 Symfony Debug Component symfony/debug-bundle v4.1.8 v4.1.8 Symfony DebugBundle symfony/debug-pack v1.0.6 v1.0.6 A debug pack for Symfony projects symfony/dependency-injection v4.1.8 v4.1.8 Symfony DependencyInjection Component symfony/doctrine-bridge v4.1.8 v4.1.8 Symfony Doctrine Bridge symfony/dom-crawler v4.1.8 v4.1.8 Symfony DomCrawler Component symfony/dotenv v4.1.8 v4.1.8 Registers environment variables from a .env file symfony/event-dispatcher v4.1.8 v4.1.8 Symfony EventDispatcher Component symfony/filesystem v4.1.8 v4.1.8 Symfony Filesystem Component symfony/finder v4.1.8 v4.1.8 Symfony Finder Component symfony/flex v1.1.8 v1.1.8 Composer plugin for Symfony symfony/form v4.1.8 v4.1.8 Symfony Form Component symfony/framework-bundle v4.1.8 v4.1.8 Symfony FrameworkBundle symfony/http-foundation v4.1.8 v4.1.8 Symfony HttpFoundation Component symfony/http-kernel v4.1.8 v4.1.8 Symfony HttpKernel Component symfony/inflector v4.1.8 v4.1.8 Symfony Inflector Component symfony/intl v4.1.8 v4.1.8 A PHP replacement layer for the C intl extension that includes additional data from the ICU library. symfony/monolog-bridge v4.1.8 v4.1.8 Symfony Monolog Bridge symfony/monolog-bundle v3.3.1 v3.3.1 Symfony MonologBundle symfony/options-resolver v4.1.8 v4.1.8 Symfony OptionsResolver Component symfony/orm-pack v1.0.5 v1.0.5 A pack for the Doctrine ORM symfony/phpunit-bridge v4.1.8 v4.1.8 Symfony PHPUnit Bridge symfony/polyfill-ctype v1.10.0 v1.10.0 Symfony polyfill for ctype functions symfony/polyfill-intl-icu v1.10.0 v1.10.0 Symfony polyfill for intl's ICU-related data and classes symfony/polyfill-mbstring v1.10.0 v1.10.0 Symfony polyfill for the Mbstring extension symfony/polyfill-php72 v1.10.0 v1.10.0 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions symfony/process v4.1.8 v4.1.8 Symfony Process Component symfony/profiler-pack v1.0.3 v1.0.3 A pack for the Symfony web profiler symfony/property-access v4.1.8 v4.1.8 Symfony PropertyAccess Component symfony/proxy-manager-bridge v4.1.8 v4.1.8 Symfony ProxyManager Bridge symfony/routing v4.1.8 v4.1.8 Symfony Routing Component symfony/security v4.1.8 v4.1.8 Symfony Security Component symfony/security-bundle v4.1.8 v4.1.8 Symfony SecurityBundle symfony/stopwatch v4.1.8 v4.1.8 Symfony Stopwatch Component symfony/templating v4.1.8 v4.1.8 Symfony Templating Component symfony/translation v4.1.8 v4.1.8 Symfony Translation Component symfony/twig-bridge v4.1.8 v4.1.8 Symfony Twig Bridge symfony/twig-bundle v4.1.8 v4.1.8 Symfony TwigBundle symfony/validator v4.1.8 v4.1.8 Symfony Validator Component symfony/var-dumper v4.1.8 v4.1.8 Symfony mechanism for exploring and dumping PHP variables symfony/web-profiler-bundle v4.1.8 v4.1.8 Symfony WebProfilerBundle symfony/web-server-bundle v4.1.8 v4.1.8 Symfony WebServerBundle symfony/yaml v4.1.8 v4.1.8 Symfony Yaml Component

Symfony CMF packages

$ composer show --latest 'symfony-cmf/*'

symfony-cmf/core-bundle 2.1.0 2.1.0 Symfony CMF Core Bundle symfony-cmf/routing 2.1.0 2.1.0 Extends the Symfony routing component for dynamic routes and chaining several routers symfony-cmf/routing-bundle 2.1.1 2.1.1 Symfony RoutingBundle

Subject

Old template namespace definition no longer working: Unable to find template "CmfCoreBundle:Form:checkbox_url_label_form_type.html.twig" The issue is resolved when i replace CmfCoreBundle:Form:checkbox_url_label_form_type.html.twig with @CmfCore/Form/checkbox_url_label_form_type.html.twig and if that is the best solution im happy to submit a PR for it.

Steps to reproduce

i extended the form layout {% extends "form_div_layout.html.twig" %} and got the error on any form i try to render

Expected results

a form rendered

Actual results

Twig_Error_Loader:
Unable to find template "CmfCoreBundle:Form:checkbox_url_label_form_type.html.twig" (looked into: /var/www/app/vendor/knplabs/knp-menu/src/Knp/Menu/Resources/views, /var/www/app/templates, /var/www/app/vendor/symfony/twig-bridge/Resources/views/Form).

  at Bundle/BricksBundle/Resources/views/form.html.twig:16
  at Twig_Loader_Filesystem->findTemplate('CmfCoreBundle:Form:checkbox_url_label_form_type.html.twig')
     (/var/www/app/vendor/twig/twig/lib/Twig/Loader/Filesystem.php:143)
  at Twig_Loader_Filesystem->getCacheKey('CmfCoreBundle:Form:checkbox_url_label_form_type.html.twig')
     (/var/www/app/vendor/twig/twig/lib/Twig/Environment.php:270)
  at Twig_Environment->getTemplateClass('CmfCoreBundle:Form:checkbox_url_label_form_type.html.twig')
     (/var/www/app/vendor/twig/twig/lib/Twig/Environment.php:350)
  at Twig_Environment->loadTemplate('CmfCoreBundle:Form:checkbox_url_label_form_type.html.twig')
     (/var/www/app/vendor/symfony/twig-bridge/Form/TwigRendererEngine.php:157)
  at Symfony\Bridge\Twig\Form\TwigRendererEngine->loadResourcesFromTheme('_edit_media_form_edit_media_form', 'CmfCoreBundle:Form:checkbox_url_label_form_type.html.twig')
     (/var/www/app/vendor/symfony/twig-bridge/Form/TwigRendererEngine.php:111)
  at Symfony\Bridge\Twig\Form\TwigRendererEngine->loadResourceForBlockName('_edit_media_form_edit_media_form', object(FormView), '_edit_media_form_widget')
     (/var/www/app/vendor/symfony/form/AbstractRendererEngine.php:146)
  at Symfony\Component\Form\AbstractRendererEngine->loadResourceForBlockNameHierarchy('_edit_media_form_edit_media_form', object(FormView), array('form_widget', 'edit_media_form_widget', '_edit_media_form_widget'), 2)
     (/var/www/app/vendor/symfony/form/AbstractRendererEngine.php:84)
  at Symfony\Component\Form\AbstractRendererEngine->getResourceForBlockNameHierarchy(object(FormView), array('form_widget', 'edit_media_form_widget', '_edit_media_form_widget'), 2)
     (/var/www/app/vendor/symfony/form/FormRenderer.php:208)
  at Symfony\Component\Form\FormRenderer->searchAndRenderBlock(object(FormView), 'widget')

... (had to remove from the stacktrace as msg was to long
esserj commented 5 years ago

It is also fixed by activating the templating component through the framework, but I still believe its better to no longer rely on this and use twig's build-in support for namespacing?

fix in config:

framework:
    templating: { engines: ['twig'] }
dbu commented 5 years ago

indeed, we should use the build-in syntax and not rely on the optional templating component. could you please make a pull request to change the template reference?