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

Adding css class to an element generated with \Phalcon\Tag in Volt

Hello I've been reading documentation and I've encountered that I can generate for example a link with a custom class name by <?= Tag::linkTo(array('products/edit/10', 'Edit', 'class' => 'edit-btn')) ?> in .phtml but I havent found any alternative using Volt. So is there a possibility of doing that? Thank you

edited Mar '14

This is the Solution:

{{ link_to('products/edit/10', 'Edit', 'class':'edit-btn') }}


9.4k
edited Mar '14

thank you very much! since I have this topic I have another question if you dont mind. Is there a possiblity to do
{{ link_to("login", ""}} around any element? Like for example if i can create a login button, so it would look like <a href="login"> <button class="btn">Login</button> </a>

edited Mar '14

Yes of course. It's possible like this:

{{ link_to('products/edit/10', '<button>botton text</button>') }}

BUT I think it's better to style the "A" tag like button with css instead of using this kind of markup.


For example in Twitter bootstrap we have "btn" class

<a href="#" class="btn">Link</a>. 

Or you can style it yourself without using bootstrap or any other css framework.



9.4k
Accepted
answer
edited Mar '14

oh yes I havent think of that (the solution) I though it would strip the tags and stuff automaticaly so I could do that. Again thank you! and yea I'll use the boostrap aproach.