1
我已經在應用/類書面文件form.php的/ form.php的擴展核心類3.1
<?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) . ' />';
}
}
?>
,當我使用的形式::輸入這個功能調用,但它並不適用id屬性上元素。 我的代碼有什麼問題?
用法舉例
echo form::input('date', $cd->year);
O/P
<input type="text" name="date">
作爲提示,您可以隨時調用父功能,以免重複。 – 2011-04-13 16:39:36
謝謝我修改了我的函數以便有父輸入調用。 – 2011-04-14 04:35:00