Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Phalcon\Mvc\View\Engine\Volt\Exception: Unknown statement 314

Hi, I'm upgrading and old laravel application, it was wroten in Phalcon1 and now is working on Phalcon2, now I want to upgrade to the latest version of phalcon (4), we have a lot experience developing in PHP but I don't have a lot experience in Phalcon. After a lot of changes we have the problem with Volt compilation, it seems Volt doesn't work and fails in the line that we have use the set method.

Phalcon\Mvc\View\Engine\Volt\Exception: Unknown statement 314 in /var/www/html/app/frontend/views/index/login.volt on line 31

Volt in line 31 has: {% set field = 'username' %}

Thanks! PD: If any Phalcon expert can help me I have budget to hire it.

That's a really arcane, deep level error - is there a backtrace? My guess is "314" maps to a constant somewhere deep in Zephir-land.

I don't see anything wrong with that line - maybe double quotes instead? Try removing that line and see if the error persists. My inital guess is that some code earlier in the file is causing a parsing error which causes the exception later on.

edited Jun '20

Hi Dylan, thanks for your response. I have this code in the view:

{{ flashSession.output() }}
<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <div class="login-wrapper" style="margin-top: 50px; margin-bottom: 40px">
                <div style="background-color: #ffffb9;padding:20px; border: 1px dashed #ff3333; margin-bottom: 20px">
                    <h4 class="color-red" style="margin-top: 0">
                        Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
                    </h4>
                    <p>
                        Apreciados usuarios,<br/>
                        Aenean malesuada urna tincidunt magna posuere, at vulputate arcu aliquet. Quisque in urna sapien. Donec dignissim, orci in imperdiet rutrum, risus augue ullamcorper diam, nec venenatis odio turpis vitae sem.</strong>
                    </p>
                </div>

                <div class="login-left-side">
                    <p class="text-center color-red f-size-l">
                      vitae dapibus nisi mattis. Praesent magna augue, pretium at mi sodales, congue malesuada quam. 
                      Proin blandit neque est, vel rhoncus ex faucibus at.r <span class="color-red">frdsf sdf sdf sfds dfsdf sdf. dsfa</span>.
                    </p>
                    <img src="img/logo_identify_land.png">
                    <img src="img/logo_astra_land.png">
                </div>
                <div class="login-right-side">
                    <form action="{{ config.app.static_uri}}acceso" method="post" class="no-restrict-submit">
                        {% cache "token" 0 %}
                            <input type="hidden" name="{{ tokenName }}" value="{{ tokenValue }}"/>
                        {% endcache %}

                    {% set field = "username" %}
                        <div class="form-group{{ errors is defined and errors.filter(field) ? ' has-error' : (_POST[field] is defined ? ' has-success' : '') }}">
                        {{ textField([ field, 'placeholder':'Nombre de usuario', 'class' : 'form-control' ]) }}
                        {% if errors is defined and errors.filter(field) %}
                            <span class="help-block">{{ current(errors.filter(field)).getMessage() }}</span>
                        {% endif %}
                        </div>
                    {% set field = 'password' %}
                        <div class="form-group{{ errors is defined and errors.filter(field) ? ' has-error' : (_POST[field] is defined ? ' has-success' : '') }}">
                        {{ passwordField([field, 'placeholder':'Contraseña', 'class' : 'form-control']) }}
                        {% if errors is defined and errors.filter(field) %}
                            <span class="help-block">{{ current(errors.filter(field)).getMessage() }}</span>
                        {% endif %}
                        </div>

                        <div class="form-group">
                            <div class="col-lg-12 text-center">
                                <p><button type="submit" name="submit_signin" class="btn btn-default color-red">Acceder</button></p>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-lg-12 text-center">
                                <a href="/acceso/recuperar-clave" class="f-size-s color-white">Olvidé mi contraseña</a>
                            </div>
                        </div>
                        <div class="clearfix" style="margin-bottom:5px"></div>
                    </form>
                    <p class="login-right-side-advertisement f-size-s color-white text-center">
                        Praesent magna augue, pretium at mi sodales, congue malesuada quam. Proin. <a href="/registro" class="color-white alt" style="text-decoration: underline">regístrese aquí</a>.
                    </p>

                </div>
                <div class="clearfix"></div>

            </div>
        </div>
    </div>
</div>

<div class="modal-content" style="width: 745px; padding:12px; margin:auto; background-color: #d5d5d5; text-align: center">
    * Si experimenta dificultades para acceder a la nueva plataforma contacte con nosotros proporcionando el nombre de usuario.<br/>
    <b><u>Información de contacto:</u></b><br/>
    AAAAAAA AAAAAAAAAAA<br/>
    Teléfono: 233 348 123<br/>
    E-mail: <a href="mailto:[email protected]">[email protected]</a><br/>
    <hr/>
    <div><small>&copy; {{ date('Y') }} fdsfsdfdsdfsfds fdsfsddfs S.A - <a href="https://www.dfsfdfdsfsddsf.dfsfsddfsdfs.com/es" target="_blank">Política de privacidad</a> - <a target="_blank" href="/nota-legal">Aviso legal</a></small></div>
</div>

Thanks!

That can't be the entirety of your file - the error is being reported on line 31, but that same line is the first line of what you've posted.

Also, I edited your response to include proper code highlighting - you can [Edit] your post to see what I changed.

Hi, I edited and add all lines of the file. Thanks!



119.8k
Accepted
answer

From line 31 up, start removing Volt tags until the error goes away. Hopefully it's just a malformed tag.

Also, I'd remove the {% cache %} tags. You're setting the cache time to zero seconds - which is the same as not caching at all, so you're not getting any caching benefit.

Hi Dylan, this works fine! Thanks a lot.



207
edited 22d ago

I have the same problem. If I use {% cache 'test' %} ... {% endcache %} I have "Unknown statement 314" error. Phalcon 4.0.6

I have the same problem. If I use {% cache 'test' %} ... {% endcache %} I have "Unknown statement 314" error. Phalcon 4.0.6

This post is 3 months old - please create your own thread for an answer to your particular problem.