Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use table_layout gives error #1182

Closed
Burgov opened this issue Jun 1, 2011 · 7 comments
Closed

Use table_layout gives error #1182

Burgov opened this issue Jun 1, 2011 · 7 comments
Labels

Comments

@Burgov
Copy link
Contributor

Burgov commented Jun 1, 2011

The twig template below gives me an error:

{% extends "::base.html.twig" %}
{% use 'TwigBundle:Form:table_layout.html.twig' %}

{% block body %}
<form action="{{ path('import') }}" method="post" {{ form_enctype(form) }}>
{{ form_widget(form) }}
</form>
{% endblock body %}

at Twig_Error ->__construct ('Template "TwigBundle:Form:table_layout.html.twig" cannot be used as a trait.')
in D:\workspace\...\app\cache\dev\twig\15\c9\9a61cfb1ef972ba94c47561910af.php at line 14

using div_layout.html.twig instead works fine.

As a plus, instead of a nice error, I get:

Notice: Undefined offset: -1 in D:\workspace\...\vendor\twig\lib\Twig\Error.php line 159 

Stack Trace

in D:\workspace\...\app\bootstrap.php.cache at line 382  -+
                return false;
            }
            if (error_reporting() & $level && $this->level & $level) {
                throw new \ErrorException(sprintf('%s: %s in %s line %d', isset($this->levels[$level]) ? $this->levels[$level] : $level, $message, $file, $line));
            }
            return false;
        }
at ErrorHandler ->handle ('8', 'Undefined offset: -1', 'D:\workspace\...\vendor\twig\lib\Twig\Error.php', '159', array('e' => object(Twig_Error_Runtime), 'currentLine' => '-1', 'currentFile' => null, 'traces' => array(array('file' => 'D:\workspace\...\vendor\twig\lib\Twig\Environment.php', 'line' => '316', 'function' => '__construct', 'class' => '__TwigTemplate_15c99a61cfb1ef972ba94c47561910af', 'type' => '->', 'args' => array(object(Twig_Environment))), array('file' => 'D:\workspace\...\vendor\symfony\src\Symfony\Bundle\TwigBundle\TwigEngine.php', 'line' => '135', 'function' => 'loadTemplate', 'class' => 'Twig_Environment', 'type' => '->', 'args' => array('MNImportBundle:Default:index.html.twig')), array('file' => 'D:\workspace\...\vendor\symfony\src\Symfony\Bundle\TwigBundle\TwigEngine.php', 'line' => '60', 'function' => 'load', 'class' => 'Symfony\Bundle\TwigBundle\TwigEngine', 'type' => '->', 'args' => array('MNImportBundle:Default:index.html.twig')), array('file' => 'D:\workspace\...\vendor\symfony\src\Symfony\Bundle\TwigBundle\TwigEngine.php', 'line' => '114', 'function' => 'render', 'class' => 'Symfony\Bundle\TwigBundle\TwigEngine', 'type' => '->', 'args' => array('MNImportBundle:Default:index.html.twig', array('form' => object(FormView)))), array('file' => 'D:\workspace\...\vendor\symfony\src\Symfony\Bundle\FrameworkBundle\Controller\Controller.php', 'line' => '93', 'function' => 'renderResponse', 'class' => 'Symfony\Bundle\TwigBundle\TwigEngine', 'type' => '->', 'args' => array('MNImportBundle:Default:index.html.twig', array('form' => object(FormView)), null)), array('file' => 'D:\workspace\...\src\MN\ImportBundle\Controller\DefaultController.php', 'line' => '14', 'function' => 'render', 'class' => 'Symfony\Bundle\FrameworkBundle\Controller\Controller', 'type' => '->', 'args' => array('MNImportBundle:Default:index.html.twig', array('form' => object(FormView)))), array('function' => 'indexAction', 'class' => 'MN\ImportBundle\Controller\DefaultController', 'type' => '->', 'args' => array()), array('file' => 'D:\workspace\...\app\bootstrap.php.cache', 'line' => '445', 'function' => 'call_user_func_array', 'args' => array(array(object(DefaultController), 'indexAction'), array())), array('file' => 'D:\workspace\...\app\bootstrap.php.cache', 'line' => '423', 'function' => 'handleRaw', 'class' => 'Symfony\Component\HttpKernel\HttpKernel', 'type' => '->', 'args' => array(object(Request), '1')), array('file' => 'D:\workspace\...\vendor\symfony\src\Symfony\Bundle\FrameworkBundle\HttpKernel.php', 'line' => '35', 'function' => 'handle', 'class' => 'Symfony\Component\HttpKernel\HttpKernel', 'type' => '->', 'args' => array(object(Request), '1', true)), array('file' => 'D:\workspace\...\app\bootstrap.php.cache', 'line' => '619', 'function' => 'handle', 'class' => 'Symfony\Bundle\FrameworkBundle\HttpKernel', 'type' => '->', 'args' => array(object(Request), '1', true)), array('file' => 'D:\workspace\...\web\app_dev.php', 'line' => '20', 'function' => 'handle', 'class' => 'Symfony\Component\HttpKernel\Kernel', 'type' => '->', 'args' => array(object(Request)))), 'i' => '0', 'trace' => array('file' => 'D:\workspace\...\vendor\twig\lib\Twig\Environment.php', 'line' => '316', 'function' => '__construct', 'class' => '__TwigTemplate_15c99a61cfb1ef972ba94c47561910af', 'type' => '->', 'args' => array(object(Twig_Environment))), 'r' => object(ReflectionClass)))
in D:\workspace\...\vendor\twig\lib\Twig\Error.php at line 159  -+
at Twig_Error ->findTemplateInfo (object(Twig_Error_Runtime), '-1', null)
in D:\workspace\...\vendor\twig\lib\Twig\Error.php at line 36  -+
at Twig_Error ->__construct ('Template "TwigBundle:Form:table_layout.html.twig" cannot be used as a trait.')
in D:\workspace\...\app\cache\dev\twig\15\c9\9a61cfb1ef972ba94c47561910af.php at line 14  -+
at __TwigTemplate_15c99a61cfb1ef972ba94c47561910af ->__construct (object(Twig_Environment))
in D:\workspace\...\vendor\twig\lib\Twig\Environment.php at line 316  -+
at Twig_Environment ->loadTemplate ('MNImportBundle:Default:index.html.twig')
in D:\workspace\...\vendor\symfony\src\Symfony\Bundle\TwigBundle\TwigEngine.php at line 135  -+
at TwigEngine ->load ('MNImportBundle:Default:index.html.twig')
in D:\workspace\...\vendor\symfony\src\Symfony\Bundle\TwigBundle\TwigEngine.php at line 60  -+
at TwigEngine ->render ('MNImportBundle:Default:index.html.twig', array('form' => object(FormView)))
in D:\workspace\...\vendor\symfony\src\Symfony\Bundle\TwigBundle\TwigEngine.php at line 114  -+
at TwigEngine ->renderResponse ('MNImportBundle:Default:index.html.twig', array('form' => object(FormView)), null)
in D:\workspace\...\vendor\symfony\src\Symfony\Bundle\FrameworkBundle\Controller\Controller.php at line 93  -+
at Controller ->render ('MNImportBundle:Default:index.html.twig', array('form' => object(FormView)))
in D:\workspace\...\src\MN\ImportBundle\Controller\DefaultController.php at line 14  -+
at DefaultController ->indexAction ()
in at line   -+
at call_user_func_array (array(object(DefaultController), 'indexAction'), array())
in D:\workspace\...\app\bootstrap.php.cache at line 445  -+
at HttpKernel ->handleRaw (object(Request), '1')
in D:\workspace\...\app\bootstrap.php.cache at line 423  -+
at HttpKernel ->handle (object(Request), '1', true)
in D:\workspace\...\vendor\symfony\src\Symfony\Bundle\FrameworkBundle\HttpKernel.php at line 35  -+
at HttpKernel ->handle (object(Request), '1', true)
in D:\workspace\...\app\bootstrap.php.cache at line 619  -+
at Kernel ->handle (object(Request))
in D:\workspace\...\web\app_dev.php at line 20  -+

Logs +-
1 error

[2011-06-01 14:51:27] request.INFO: Matched route "homepage" (parameters: "_controller": "MN\ImportBundle\Controller\DefaultController::indexAction", "_route": "homepage")
[2011-06-01 14:51:27] event.DEBUG: Notified event "onCoreRequest" to listener "Symfony\Bundle\FrameworkBundle\RequestListener".
[2011-06-01 14:51:27] event.DEBUG: Notified event "onCoreRequest" to listener "Symfony\Bundle\FrameworkBundle\Profiler\ProfilerListener".
[2011-06-01 14:51:27] event.DEBUG: Notified event "onCoreRequest" to listener "Symfony\Bundle\AsseticBundle\Listener\RequestListener".
[2011-06-01 14:51:27] event.DEBUG: Notified event "onCoreRequest" to listener "Symfony\Component\Security\Http\Firewall".
[2011-06-01 14:51:27] request.INFO: Using controller "MN\ImportBundle\Controller\DefaultController::indexAction"
[2011-06-01 14:51:27] event.DEBUG: Notified event "onCoreController" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RequestDataCollector".
[2011-06-01 14:51:27] event.DEBUG: Notified event "onCoreController" to listener "Sensio\Bundle\FrameworkExtraBundle\Controller\ControllerAnnotationParser".
[2011-06-01 14:51:27] event.DEBUG: Notified event "onCoreController" to listener "Sensio\Bundle\FrameworkExtraBundle\Controller\ParamConverterListener".
[2011-06-01 14:51:27] event.DEBUG: Notified event "onCoreController" to listener "Sensio\Bundle\FrameworkExtraBundle\View\AnnotationTemplateListener".
[2011-06-01 14:51:27] event.DEBUG: Notified event "onCoreController" to listener "Acme\DemoBundle\ControllerListener".
[2011-06-01 14:51:27] event.DEBUG: Notified event "onCoreController" to listener "JMS\SecurityExtraBundle\Controller\ControllerListener".
[2011-06-01 14:51:27] event.DEBUG: Notified event "onCoreException" to listener "Symfony\Bundle\FrameworkBundle\Profiler\ProfilerListener".
[2011-06-01 14:51:27] request.CRITICAL: ErrorException: Notice: Undefined offset: -1 in D:\workspace\...\vendor\twig\lib\Twig\Error.php line 159 (uncaught exception) at D:\workspace\...\app\bootstrap.php.cache line 382
[2011-06-01 14:51:27] event.DEBUG: Notified event "onCoreRequest" to listener "Symfony\Bundle\FrameworkBundle\RequestListener".
[2011-06-01 14:51:27] event.DEBUG: Notified event "onCoreRequest" to listener "Symfony\Bundle\FrameworkBundle\Profiler\ProfilerListener".
[2011-06-01 14:51:27] event.DEBUG: Notified event "onCoreRequest" to listener "Symfony\Bundle\AsseticBundle\Listener\RequestListener".
[2011-06-01 14:51:27] event.DEBUG: Notified event "onCoreRequest" to listener "Symfony\Component\Security\Http\Firewall".
[2011-06-01 14:51:27] request.INFO: Using controller "Symfony\Bundle\FrameworkBundle\Controller\ExceptionController::showAction"
[2011-06-01 14:51:27] event.DEBUG: Notified event "onCoreController" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RequestDataCollector".
[2011-06-01 14:51:27] event.DEBUG: Notified event "onCoreController" to listener "Sensio\Bundle\FrameworkExtraBundle\Controller\ControllerAnnotationParser".
[2011-06-01 14:51:27] event.DEBUG: Notified event "onCoreController" to listener "Sensio\Bundle\FrameworkExtraBundle\Controller\ParamConverterListener".
[2011-06-01 14:51:27] event.DEBUG: Notified event "onCoreController" to listener "Sensio\Bundle\FrameworkExtraBundle\View\AnnotationTemplateListener".
[2011-06-01 14:51:27] event.DEBUG: Notified event "onCoreController" to listener "Acme\DemoBundle\ControllerListener".
[2011-06-01 14:51:27] event.DEBUG: Notified event "onCoreController" to listener "JMS\SecurityExtraBundle\Controller\ControllerListener".
@vicb
Copy link
Contributor

vicb commented Jun 1, 2011

{% form_theme form 'TwigBundle:Form:table_layout.html.twig' %} is one way to do this.

You can find a cookbook article @ http://symfony.com/doc/current/cookbook/form/twig_form_customization.html

@Burgov
Copy link
Contributor Author

Burgov commented Jun 1, 2011

Ok, that does work, thanks. Still, I feel the error is somewhat out of place, as "use"-ing div_layout works fine.

And apart from that the error handling seems to be faulty here

@stof
Copy link
Member

stof commented Jun 1, 2011

A template is not traitable if it extends another one. The table layout extends the div layout so it does not work.

@stof
Copy link
Member

stof commented Jun 1, 2011

@fabpot
Copy link
Member

fabpot commented Jun 5, 2011

The error message handling has been fixed (fabpot/Twig@3cf3573 and fabpot/Twig@7e45720).

@Burgov
Copy link
Contributor Author

Burgov commented Jun 5, 2011

Nice. The template error was just me not reading the docs well, so we can close this one :)

@Burgov Burgov closed this as completed Jun 5, 2011
@Burgov
Copy link
Contributor Author

Burgov commented Jun 7, 2011

Nice, 6737bd3 makes both methods possible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants