Yii Framework: Create a link with multiple parameters CHTML::link
14,536
Solution 1
Documentation: http://www.yiiframework.com/wiki/48/by-example-chtml/
<?php echo CHtml::link('Link Text',array('controller/action',
'param1'=>'value1',
'param2'=>'value2',
'param3'=>'value3')); ?>
Solution 2
<?php echo CHtml::link('Link Text',
Yii::app()->createUrl('controller/action',array(
'param1'=>'value1',
'param2'=>'value2',
'param3'=>'value3')); ?>
Author by
John Zumbrum
John Zumbrum, Software Engineering Lead and Product Designer Passionate about the full software development life cycle from concept through deployment, and excited about crafting meaningful web applications and businesses. Specialties: PHP, Python, Flask, MySQL, MongoDB, C#, ASP.NET MVC, SQL Server, Web Applications
Updated on June 28, 2022Comments
-
John Zumbrum almost 2 years
I would like to link to a different controller, passing in multiple parameters.
-
John Zumbrum almost 12 yearsCan you provide a little more detail to explain what advantages the createUrl method provides in this case?
-
adamors almost 12 yearsThere are no advantages in this case, the link will be parsed the same way.