How can I assign an id and class with $this->Html->link(..);?

你。 提交于 2019-12-07 03:42:14

问题


echo $this->Html->link(
    'more',
    array(
        'controller'=>'posts',
        'action'=>'view',
        $post['Post']['id']
    ) 
);

How can I assign an id and class for this anchor/link? I want to override its css rule.


回答1:


HTML attributes can be specified in an array as the third parameter.

echo $this->Html->link(
    'more',
    array(
        'controller'=>'posts',
        'action'=>'view',
        $post['Post']['id']
    ),
    array(
        'id' => 'myId',
        'class' => 'myClass'
    )
);

More info in the Cookbook 2.x for the 2.x version or Cookbook 1.3 for CakePHP 1.3.



来源:https://stackoverflow.com/questions/6889955/how-can-i-assign-an-id-and-class-with-this-html-link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!