问题
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