cakephp - 如何使用 $this->Html->link(..); 分配 ID 和类?

标签 cakephp cakephp-1.3

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

如何为此 anchor /链接分配 ID 和类?我想覆盖它的 css 规则。

最佳答案

HTML 属性可以在数组中指定为第三个参数。

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

更多信息在 Cookbook 2.x对于 2.x 版本或 Cookbook 1.3适用于 CakePHP 1.3。

关于cakephp - 如何使用 $this->Html->link(..); 分配 ID 和类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6889955/

相关文章:

php - CakePHP - 使用 JOIN 有效地搜索 3 个表

测试是否抛出 cakeError()

php - CakePHP 插件的自动数据库设置

php - 在 IDE 中为 CakePHP 完成代码

authentication - Cakephp 授权 : $this->Auth->loginError message

php - CakePHP 应该将 number_format(与 View 相关的逻辑)放在哪里?

MySQL数据库-备份数据库时出错

php - HybirdAuth 用户配置文件请求失败

php - 保存记录时未插入特定列

php - CakePHP 如何从元素内部添加脚本()?