CFormElement
鍖 | system.web.form |
---|---|
缁ф壙 | abstract class CFormElement » CComponent |
瀛愮被 | CForm, CFormButtonElement, CFormInputElement, CFormStringElement |
婧愯嚜 | 1.1 |
鐗堟湰 | $Id: CFormElement.php 3426 2011-10-25 00:01:09Z alexander.makarow $ |
婧愮爜 | framework/web/form/CFormElement.php |
CFormElement 鏄悇绉嶈〃鍗曞厓绱犵殑鍩虹被銆
CFormElement 瀹炵幇浜嗚幏鍙栧拰璁剧疆浠绘剰鐨勫睘鎬х殑鏂规硶銆
CFormElement 瀹炵幇浜嗚幏鍙栧拰璁剧疆浠绘剰鐨勫睘鎬х殑鏂规硶銆
鍏叡灞炴
灞炴 | 绫诲瀷 | 鎻忚堪 | 瀹氫箟鍦 |
---|---|---|---|
attributes | array | 閫氳繃杩欎釜瀵硅薄鏉ヨ〃鐜癏TML鍏冪礌鐨勫睘鎬у垪琛(name=>value)銆 | CFormElement |
parent | mixed | 杩欎釜鍏冪礌鐨勭湡绯荤埗绫汇傚畠鍙兘鏄CForm瀵硅薄锛屼篃鍙兘鏄CBaseController瀵硅薄銆 (鎺у埗鍣ㄦ垨鎸備欢)銆 | CFormElement |
visible | boolean | 杩斿洖鍊艰鏄庤繖涓厓绱犳槸鍚﹀彲瑙佸苟闇瑕佹覆鏌撱 | CFormElement |
鍏叡鏂规硶
鏂规硶 | 鎻忚堪 | 瀹氫箟鍦 |
---|---|---|
__call() | 濡傛灉绫讳腑娌℃湁璋冪殑鏂规硶鍚嶏紝鍒欒皟鐢ㄨ繖涓柟娉曘 | CComponent |
__construct() | 鏋勯犲櫒銆 | CFormElement |
__get() | 杩斿洖灞炴у笺 | CFormElement |
__isset() | 妫鏌ヤ竴涓睘鎬ф槸鍚︿负null銆 | CComponent |
__set() | 璁剧疆灞炴у笺 | CFormElement |
__toString() | 灏嗗璞¤浆鎹负瀛楃涓层 | CFormElement |
__unset() | 璁剧疆涓涓粍浠剁殑灞炴т负null銆 | CComponent |
asa() | 杩斿洖杩欎釜鍚嶅瓧鐨勮涓哄璞° | CComponent |
attachBehavior() | 闄勫姞涓涓涓哄埌缁勪欢銆 | CComponent |
attachBehaviors() | 闄勫姞涓涓涓哄垪琛ㄥ埌缁勪欢銆 | CComponent |
attachEventHandler() | 涓轰簨浠堕檮鍔犱竴涓簨浠跺鐞嗙▼搴忋 | CComponent |
canGetProperty() | 纭畾灞炴ф槸鍚﹀彲璇汇 | CComponent |
canSetProperty() | 纭畾灞炴ф槸鍚﹀彲鍐欍 | CComponent |
configure() | 鏍规嵁鍒濆鍖栫殑鍊兼潵閰嶇疆杩欎釜瀵硅薄銆 | CFormElement |
detachBehavior() | 浠庣粍浠朵腑鍒嗙涓涓涓恒 | CComponent |
detachBehaviors() | 浠庣粍浠朵腑鍒嗙鎵鏈夎涓恒 | CComponent |
detachEventHandler() | 鍒嗙涓涓瓨鍦ㄧ殑浜嬩欢澶勭悊绋嬪簭銆 | CComponent |
disableBehavior() | 绂佺敤涓涓檮鍔犺涓恒 | CComponent |
disableBehaviors() | 绂佺敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 | CComponent |
enableBehavior() | 鍚敤涓涓檮鍔犺涓恒 | CComponent |
enableBehaviors() | 鍚敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 | CComponent |
evaluateExpression() | 璁$畻涓涓狿HP琛ㄨ揪寮忥紝鎴栨牴鎹粍浠朵笂涓嬫枃鎵ц鍥炶皟銆 | CComponent |
getEventHandlers() | 杩斿洖涓涓簨浠剁殑闄勫姞澶勭悊绋嬪簭鍒楄〃銆 | CComponent |
getParent() | 杩斿洖杩欎釜鍏冪礌鐨勭湡绯荤埗绫汇傚畠鍙兘鏄CForm瀵硅薄锛屼篃鍙兘鏄CBaseController瀵硅薄銆 (鎺у埗鍣ㄦ垨鎸備欢)銆 | CFormElement |
getVisible() | 杩斿洖鍊艰鏄庤繖涓厓绱犳槸鍚﹀彲瑙佸苟闇瑕佹覆鏌撱 | CFormElement |
hasEvent() | 纭畾涓涓簨浠舵槸鍚﹀畾涔夈 | CComponent |
hasEventHandler() | 妫鏌ヤ簨浠舵槸鍚︽湁闄勫姞鐨勫鐞嗙▼搴忋 | CComponent |
hasProperty() | 纭畾灞炴ф槸鍚﹁瀹氫箟銆 | CComponent |
raiseEvent() | 鍙戣捣涓涓簨浠躲 | CComponent |
render() | 娓叉煋杩欎釜鍏冪礌銆 | CFormElement |
setVisible() | 璁剧疆杩欎釜鍏冪礌鏄惁鍙骞堕渶瑕佹覆鏌撱 | CFormElement |
灞炴ц缁
attributes
灞炴
public array $attributes;
閫氳繃杩欎釜瀵硅薄鏉ヨ〃鐜癏TML鍏冪礌鐨勫睘鎬у垪琛(name=>value)銆
parent
灞炴
鍙
public mixed getParent()
杩欎釜鍏冪礌鐨勭湡绯荤埗绫汇傚畠鍙兘鏄CForm瀵硅薄锛屼篃鍙兘鏄CBaseController瀵硅薄銆 (鎺у埗鍣ㄦ垨鎸備欢)銆
visible
灞炴
杩斿洖鍊艰鏄庤繖涓厓绱犳槸鍚﹀彲瑙佸苟闇瑕佹覆鏌撱 杩欎釜鏂规硶灏嗚皟鐢evaluateVisible鏉ョ‘瀹氳繖涓厓绱犳槸鍚﹀彲瑙併
鏂规硶璇︾粏
__construct()
鏂规硶
public void __construct(mixed $config, mixed $parent)
| ||
$config | mixed | 杩欎釜鍏冪礌鐨勯厤缃 |
$parent | mixed | 杩欎釜鍏冪礌鐨勭湡绯荤埗绫汇 |
婧愮爜锛 framework/web/form/CFormElement.php#47 (鏄剧ず)
public function __construct($config,$parent)
{
$this->configure($config);
$this->_parent=$parent;
}
鏋勯犲櫒銆
鍙傝
__get()
鏂规硶
public mixed __get(string $name)
| ||
$name | string | 灞炴у悕 |
{return} | mixed | 灞炴у |
婧愮爜锛 framework/web/form/CFormElement.php#78 (鏄剧ず)
public function __get($name)
{
$getter='get'.$name;
if(method_exists($this,$getter))
return $this->$getter();
else if(isset($this->attributes[$name]))
return $this->attributes[$name];
else
throw new CException(Yii::t('yii','Property "{class}.{property}" is not defined.',
array('{class}'=>get_class($this), '{property}'=>$name)));
}
杩斿洖灞炴у笺 涓嶈璋冪敤杩欎釜鏂规硶銆傝繖鏄竴涓鎴戜滑瑕嗙洊浜嗙殑PHP鐨勯瓟鏈柟娉曪紝 瀹冨厑璁稿涓嬭娉曟潵璇诲彇灞炴у硷細
$value=$element->propertyName; $value=$element->attributeName;
鍙傝
__set()
鏂规硶
public void __set(string $name, mixed $value)
| ||
$name | string | 灞炴у悕 |
$value | mixed | 灞炴у |
婧愮爜锛 framework/web/form/CFormElement.php#102 (鏄剧ず)
public function __set($name,$value)
{
$setter='set'.$name;
if(method_exists($this,$setter))
$this->$setter($value);
else
$this->attributes[$name]=$value;
}
璁剧疆灞炴у笺 涓嶈璋冪敤杩欎釜鏂规硶銆傝繖鏄竴涓鎴戜滑瑕嗙洊鐨凱HP鐨勯瓟鏈柟娉曪紝 鍏佽鐢ㄥ涓嬭娉曡缃竴涓睘鎬х殑鍊笺
$this->propertyName=$value; $this->attributeName=$value;
鍙傝
__toString()
鏂规硶
public string __toString()
| ||
{return} | string | 浠h〃杩欎釜瀹炰綋鐨勫瓧绗︿覆銆 |
婧愮爜锛 framework/web/form/CFormElement.php#60 (鏄剧ず)
public function __toString()
{
return $this->render();
}
灏嗗璞¤浆鎹负瀛楃涓层 杩欐槸涓涓狿HP鐨勯瓟鏈柟娉曘 榛樿瀹炵幇鏄皟鐢render 杩斿洖娓叉煋缁撴灉銆
configure()
鏂规硶
public void configure(mixed $config)
| ||
$config | mixed | 杩欎釜瀵硅薄鐨勯厤缃 瀹冨彲浠ユ槸琛ㄧず灞炴у悕鍜屽畠浠殑鍒濆鍖栧肩殑鏁扮粍銆 瀹冧篃鍙互鏄兘澶熻繑鍥炰竴涓厤缃暟缁勭殑鏂囦欢鍚岻t 鎴朠HP鑴氭湰銆 |
婧愮爜锛 framework/web/form/CFormElement.php#118 (鏄剧ず)
public function configure($config)
{
if(is_string($config))
$config=require(Yii::getPathOfAlias($config).'.php');
if(is_array($config))
{
foreach($config as $name=>$value)
$this->$name=$value;
}
}
鏍规嵁鍒濆鍖栫殑鍊兼潵閰嶇疆杩欎釜瀵硅薄銆
evaluateVisible()
鏂规硶
protected boolean evaluateVisible()
| ||
{return} | boolean | 杩欎釜鍏冪礌鏄惁鍙銆傞粯璁や负true銆 |
婧愮爜锛 framework/web/form/CFormElement.php#164 (鏄剧ず)
protected function evaluateVisible()
{
return true;
}
璇勪及杩欎釜鍏冪礌鏄惁鍙銆 瀛愮被搴旇瑕嗙洊杩欎釜鏂规硶鏉ュ疄鐜扮湡瀹炵殑绠楁硶 鏉ョ‘瀹氬厓绱犵殑鍙鎬с
getParent()
鏂规硶
public mixed getParent()
| ||
{return} | mixed | 杩欎釜鍏冪礌鐨勭湡绯荤埗绫汇傚畠鍙兘鏄CForm瀵硅薄锛屼篃鍙兘鏄CBaseController瀵硅薄銆 (鎺у埗鍣ㄦ垨鎸備欢)銆 |
婧愮爜锛 framework/web/form/CFormElement.php#153 (鏄剧ず)
public function getParent()
{
return $this->_parent;
}
getVisible()
鏂规硶
public boolean getVisible()
| ||
{return} | boolean | 杩欎釜鍏冪礌鏄惁鍙骞堕渶瑕佹覆鏌撱 |
婧愮爜锛 framework/web/form/CFormElement.php#134 (鏄剧ず)
public function getVisible()
{
if($this->_visible===null)
$this->_visible=$this->evaluateVisible();
return $this->_visible;
}
杩斿洖鍊艰鏄庤繖涓厓绱犳槸鍚﹀彲瑙佸苟闇瑕佹覆鏌撱 杩欎釜鏂规硶灏嗚皟鐢evaluateVisible鏉ョ‘瀹氳繖涓厓绱犳槸鍚﹀彲瑙併
render()
鏂规硶
abstract public string render()
| ||
{return} | string | 娓叉煋缁撴灉 |
娓叉煋杩欎釜鍏冪礌銆
setVisible()
鏂规硶
public void setVisible(boolean $value)
| ||
$value | boolean | 杩欎釜鍏冪礌鏄惁鍙骞堕渶瑕佹覆鏌撱 |
婧愮爜锛 framework/web/form/CFormElement.php#144 (鏄剧ず)
public function setVisible($value)
{
$this->_visible=$value;
}