Yii Framework v1.1.10 绫诲弬鑰

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 瀹炵幇浜嗚幏鍙栧拰璁剧疆浠绘剰鐨勫睘鎬х殑鏂规硶銆

鍏叡灞炴

闅愯棌缁ф壙灞炴

灞炴绫诲瀷鎻忚堪瀹氫箟鍦
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

鍙椾繚鎶ゆ柟娉

闅愯棌缁ф壙鏂规硶

鏂规硶鎻忚堪瀹氫箟鍦
evaluateVisible() 璇勪及杩欎釜鍏冪礌鏄惁鍙銆 CFormElement

灞炴ц缁

attributes 灞炴
public array $attributes;

閫氳繃杩欎釜瀵硅薄鏉ヨ〃鐜癏TML鍏冪礌鐨勫睘鎬у垪琛(name=>value)銆

parent 灞炴 鍙
public mixed getParent()

杩欎釜鍏冪礌鐨勭湡绯荤埗绫汇傚畠鍙兘鏄CForm瀵硅薄锛屼篃鍙兘鏄CBaseController瀵硅薄銆 (鎺у埗鍣ㄦ垨鎸備欢)銆

visible 灞炴
public boolean getVisible()
public void setVisible(boolean $value)

杩斿洖鍊艰鏄庤繖涓厓绱犳槸鍚﹀彲瑙佸苟闇瑕佹覆鏌撱 杩欎釜鏂规硶灏嗚皟鐢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 娓叉煋缁撴灉
婧愮爜锛 framework/web/form/CFormElement.php#39 (鏄剧ず)
abstract function render();

娓叉煋杩欎釜鍏冪礌銆

setVisible() 鏂规硶
public void setVisible(boolean $value)
$value boolean 杩欎釜鍏冪礌鏄惁鍙骞堕渶瑕佹覆鏌撱
婧愮爜锛 framework/web/form/CFormElement.php#144 (鏄剧ず)
public function setVisible($value)
{
    
$this->_visible=$value;
}

Copyright © 2008-2011 by Yii Software LLC
All Rights Reserved.