We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Twig integration, edit form no values in inputs

I'm trying tu use Twig in my project. Made CRUD with scaffold and everything works with Volt but when I try to use Twig and add styling to my form it does not. Input has no value. Only the properties that I put manually (name, id, class, etc.). How do You access value (for input) field from Twig to get value for edit? What am I doing wrong?

This works

<div class="form-group">
    <label for="first_name" class="col-sm-2 control-label">First  Name</label>
    <div class="col-sm-10">
        {{ textField("first_name") }}
    </div>

</div>

This not

<div class="form-group">
    <label for="first_name" class="col-sm-2 control-label">First Name</label>
    <div class="col-sm-10">
       {{ textField({"name" : "first_name", "id" : "first_name", "class" : "form-control" }) }}
    </div>

</div>
edited Jul '16

Just silly question - why you want to use twig ? Volt is almost like twig(same syntax) but much much much much much much faster.

To be honest i don't see anywhere in twig docs something like textField.

Long story... I'm forced to use it by PM because in our company "everybody knows twig" and i have to do it with Twig. Is it possible with Twig?

Agree with @Wojciech, but anyway have you read the docs here

Also there is an Incubator for Twig on github: https://github.com/phalcon/incubator/tree/master/Library/Phalcon/Mvc/View/Engine

edited Jul '16

But volt has the same syntax, why even use phalcon then? There is no textField tbh in twig, just don't see it anywhere in docs. Don't know exactly what you want to achieve ?

Also if you want to use Phalcon/Tag::textField then you should call text_field in volt. I guess you need to add it to twig extension this function if you want to use it in twig.



827
Accepted
answer

After consideration I dumped Twig and went back to Volt. Now everything works. Too much hassle with Twig

edited Jul '16

Also twig creates A LOT of classes etc, it's really slowing down whole application, even on production with twig cache. On volt on another hand if you have for example 20 includes then on final template you will get ONE plain php, on twig not.

Your teammates will most likely not even notice they are writing in Volt :P

After all performance > unskilled manager [email protected] :)

edited Jul '16

Long story... I'm forced to use it by PM because in our company "everybody knows twig" and i have to do it with Twig. Is it possible with Twig?

I'm sick and tired of those 'PM' smart asses who only try to impose bad things on the project, and they are not the ones who develop the project... the only reasonable outcome was to use Volt as you learned already.

And the argument - 'everybody knows something' is just plain wrong, then let's use COBOL since that was highly popular back in 1970's.