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

add class css in form.render()

I'm using Phalcon\Forms, in form.render html ('name'). I want to add a css class like this: form.render ('name', css class add here). in case I don't want to use $ this-> name-> setAttributes (array ());

thanks!



98.9k
Accepted
answer

Just pass an array of attributes as the second parameter of render:

form.render("name", ["class": "my-class"])


20.3k

Thanks so much!