扩展Kohana 3.1中的核心类
|
我已经在application / classes / form.php中编写了文件form.php
<?php defined(\'SYSPATH\') or die(\'No direct script access.\');
class Form extends Kohana_Form {
public static function input($name, $value = NULL, array $attributes = NULL) {
// Set the input name
$attributes[\'name\'] = $name;
// Set the input value
$attributes[\'value\'] = $value;
if (!isset($attributes[\'id\'])) {
$attributes[\'id\']= $value;
}
if (!isset($attributes[\'type\'])) {
// Default type is text
$attributes[\'type\'] = \'text\';
}
return \'<input\' . HTML::attributes($attributes) . \' />\';
}
}
?>
当我使用form :: input时,此函数正在调用,但未在element上应用id属性。
我的代码有什么问题?
使用范例
echo form::input(\'date\', $cd->year );
o / p
<input type=\"text\" name=\"date\">
没有找到相关结果
已邀请:
2 个回复
泉秘胁
参数(在您的情况下为
)不是
。
将跳过具有
值的属性;您的自定义输入法会添加一个等于value的id,因此,如果value为
,则id也会太大,并且不会呈现为属性。
篮肥炼皖