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

LinkTo works not as expected

I have a named route $router->add("/", array( 'controller' => 'index', 'action' => 'index' ))->setName('homepage');

In view I'm trying to use a helper: Tag::linkTo(array('for' => 'homepage', 'id' => 'backLink'), 'back to homepage') but it is produce a wrong link: <a id="backLink" for="homepage" href="/"></a>

Thank for help in advance!



1.2k

ops, html escaped.. link is: <a id="backLink" for="homepage" href="/"></a>

Look at here: https://github.com/phalcon/cphalcon/issues/238

Solution:

Tag::linkTo(array('for' => 'homepage', 'id' => 'backLink', text => 'back to homepage'))


1.2k

Thank you! Nested arrays must be used.

Tag::linkTo(array(array('for' => 'homepage', 'id' => 'backLink'), 'back to homepage'))

Hope docs will be fixed on the site.