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

Problems with {{ text_field(...) }}

If i do a {{ text_field("user") }}, I've no problems. But, if I do a {{ text_field("user", "class" : "form-control") }}, apache2 just crashes, throwing me PHP Parse error: syntax error, unexpected "=>" (T_DOUBLE_ARROW) in...

What?

edited Aug '14
//{{ text_field("user", ["class" : "form-control"]) }}

Maybe try add brackets around - which will cause it to be array, and => is and assignment for elements in arrays. or event bracked around in all text field like

//{{ text_field(["user", "class" : "form-control"]) }}

Tried that code above, is not working, but first example of my code is working, also your version of code is working for me PHP 5.4 version, Phalcon 1.3.1 My version doesnt make error, but it doesnt add class, try to update Php version, or tell your phalcon version



33.8k
Accepted
answer

I've PHP 5.5. I retried with your code, didn't work.

I retry to do with my code, it works.

Just one thing: magic

try this. it works for me on phalcon 2.0

{{ text_field("user", ["class" : "form-control"]) }}