帮我在 Yii 中找到 $htmlOption 描述 [英] Help me to find $htmlOption Description in Yii

查看:23
本文介绍了帮我在 Yii 中找到 $htmlOption 描述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 API 中搜索没有成功.$htmlOption 键的描述不完整.我对一些公共方法特别感兴趣,比如fileField($model, $attribute, $htmlOptions=array ())"和其他类 CActiveForm.

I searched in API without success. There is an incomplete description of the keys of $htmlOption. I am particularly interested in some public methods like "fileField($model, $attribute, $htmlOptions=array ())" and others of class CActiveForm.

推荐答案

通常,$htmlOptions 数组由正在生成的 HTML 元素描述.数组实际上就是 HTML 元素的属性".键是属性名称.因此,如果您使用 CHtml::Image 生成图像,则src"是有效的 $htmlOption 键.如果您生成 CHtml::Link,则href"是有效的 $htmlOption 键.

In general, the $htmlOptions array is described by the HTML element being generated. The array is literally the "attributes" of the HTML element. The keys are the attributes names. So if you are generating an image with CHtml::Image then "src" is a valid $htmlOption key. If you generating a CHtml::Link, then "href" is a valid $htmlOption key.

如果您查看文档,CHtml 的 $htmlOptions 参数的说明::link() 元素是:

If you look in the documentation, the description for $htmlOptions parameter of the CHtml::link() element is:

额外的 HTML 属性.除了普通的 HTML 属性外,还可以识别一些特殊的属性(更多详细信息,请参阅 clientChange 和 tag.)

additional HTML attributes. Besides normal HTML attributes, a few special attributes are also recognized (see clientChange and tag for more details.)

我通常使用 $htmlOptions 数组向 HTML 元素添加类、ID 或样式,如下所示:

I usually use the $htmlOptions array to add classes, IDs or styles to an HTML element, like so:

<?php echo CHtml::link("Click Me","http://stackoverflow.com",array("id"=>"myId","class"=>"class1 class2","style"=>"color: #f00;")); ?>

这将呈现以下代码:

<a href="http://stackoverflow.com" id="myId" class="class1 class2" style="color: #f00;">Click Me</a>

Yii 允许在 $htmlOptions 数组中为某些元素(链接、按钮和其他一些元素)提供几个额外的特殊"AJAX 选项.它们允许您创建 AJAX 链接、添加 JS 确认弹出窗口等.这些选项描述如下:

There are a couple of extra "special" AJAX options that Yii allows in the $htmlOptions array for some elements (link, button, and a few others). They let you create AJAX links, add JS confirm popups, etc. These options are described here:

http://www.yiiframework.com/doc/api/CHtml#客户端更改详细信息

对于fileField元素,您可以在这里查找相关属性允许在 $htmlOptions 数组中.

For the fileField element, you can look up the relevant attributes here which will be allowed in the $htmlOptions array.

这篇关于帮我在 Yii 中找到 $htmlOption 描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆