Yii Framework v1.1.10 绫诲弬鑰

CInputWidget

system.web.widgets
缁ф壙 abstract class CInputWidget » CWidget » CBaseController » CComponent
瀛愮被 CAutoComplete, CMaskedTextField, CMultiFileUpload, CStarRating
婧愯嚜 1.0
鐗堟湰 $Id: CInputWidget.php 3515 2011-12-28 12:29:24Z mdomba $
婧愮爜 framework/web/widgets/CInputWidget.php
CInputWidget 鏄悇绉嶆敹闆嗙敤鎴疯緭鍏ョ殑灏忕墿浠剁被鐨勫熀绫汇

CInputWidget 澹版槑浜嗚緭鍏ュ皬鐗╀欢鐨勯氱敤灞炴с備竴涓緭鍏ュ皬鐗╀欢 鍙互涓庝竴涓ā鍨嬪拰灞炴х浉鍏宠仈锛屾垨涓庝竴涓悕瀛椾笌鍊肩浉鍏宠仈銆 濡傛灉鏄墠鑰咃紝灏忕墿浠剁殑鍚嶅瓧涓庡煎皢鑷姩鐢熸垚銆 缁ф壙鐨勫瓙绫诲彲浠ヤ娇鐢resolveNameIDhasModel

鍏叡灞炴

闅愯棌缁ф壙灞炴

灞炴绫诲瀷鎻忚堪瀹氫箟鍦
actionPrefix string actions鐨処D鐨勫墠缂銆 褰撳井浠跺湪CController::actions涓0鏄庝簡 鍔ㄤ綔鎻愪緵鑰咃紝鍙互涓哄叾鍔ㄤ綔鐨処D鎸囧畾鍓嶇紑浠ュ尯鍒 浜庡埆鐨勫井浠舵垨鎺у埗鍣ㄣ傚綋寰欢鐢ㄤ簬鎺у埗鍣 鐨勮鍥句腑鏃讹紝蹇呴』閰嶇疆鍚屾牱鐨勫墠缂銆 CWidget
attribute string the 涓庢灏忕墿浠剁浉鍏宠仈鐨勫睘鎬с 杩欎釜鍚嶅瓧鍙互鍖呭惈鏂规嫭鍙 (e. CInputWidget
controller CController 杩斿洖姝ゅ井浠舵墍灞炵殑鎺у埗鍣ㄣ CWidget
htmlOptions array 娓叉煋杈撳叆鏍囩鏃堕檮鍔犵殑HTML閫夐」 CInputWidget
id string 杩斿洖姝ゅ井浠剁殑ID銆傚鏋滈渶瑕佺殑璇濓紝灏嗙敓浜т竴涓柊鐨処D骞跺皢鍏惰繑鍥炪 CWidget
model CModel 涓庢灏忕墿浠剁浉鍏宠仈鐨勬暟鎹ā鍨嬨 CInputWidget
name string 杈撳叆鎺т欢鐨勫悕瀛椼傚鏋model娌℃湁璁剧疆锛屽垯蹇呴』璁剧疆姝ゅ睘鎬с CInputWidget
owner CBaseController 杩斿洖姝ゅ井浠剁殑鎵鏈夎呮垨鍒涘缓鑰呫 CWidget
skin mixed 寰欢浣跨敤鐨勭毊鑲ょ殑鍚嶇О銆傞粯璁や负鈥渄efault鈥濄 濡傛灉姝ゅ睘鎬ц缃负false锛屽井浠跺皢涓嶄細鏈夌毊鑲よ浣跨敤銆 CWidget
value string 杈撳叆鎺т欢鐨勫 CInputWidget
viewPath string 杩斿洖鍖呭惈姝ゅ井浠舵墍闇鐨勮鍥炬枃浠剁殑璺緞銆 CWidget

鍏叡鏂规硶

闅愯棌缁ф壙鏂规硶

鏂规硶鎻忚堪瀹氫箟鍦
__call() 濡傛灉绫讳腑娌℃湁璋冪殑鏂规硶鍚嶏紝鍒欒皟鐢ㄨ繖涓柟娉曘 CComponent
__construct() 鏋勯犲櫒銆 CWidget
__get() 杩斿洖涓涓睘鎬у笺佷竴涓簨浠跺鐞嗙▼搴忓垪琛ㄦ垨涓涓涓哄悕绉般 CComponent
__isset() 妫鏌ヤ竴涓睘鎬ф槸鍚︿负null銆 CComponent
__set() 璁剧疆涓涓粍浠剁殑灞炴у笺 CComponent
__unset() 璁剧疆涓涓粍浠剁殑灞炴т负null銆 CComponent
actions() 杩斿洖姝idget浣跨敤鐨勫姩浣滅殑鍒楄〃銆 CWidget
asa() 杩斿洖杩欎釜鍚嶅瓧鐨勮涓哄璞° CComponent
attachBehavior() 闄勫姞涓涓涓哄埌缁勪欢銆 CComponent
attachBehaviors() 闄勫姞涓涓涓哄垪琛ㄥ埌缁勪欢銆 CComponent
attachEventHandler() 涓轰簨浠堕檮鍔犱竴涓簨浠跺鐞嗙▼搴忋 CComponent
beginCache() Begins fragment caching. CBaseController
beginClip() Begins recording a clip. CBaseController
beginContent() Begins the rendering of content that is to be decorated by the specified view. CBaseController
beginWidget() Creates a widget and executes it. CBaseController
canGetProperty() 纭畾灞炴ф槸鍚﹀彲璇汇 CComponent
canSetProperty() 纭畾灞炴ф槸鍚﹀彲鍐欍 CComponent
createWidget() Creates a widget and initializes it. CBaseController
detachBehavior() 浠庣粍浠朵腑鍒嗙涓涓涓恒 CComponent
detachBehaviors() 浠庣粍浠朵腑鍒嗙鎵鏈夎涓恒 CComponent
detachEventHandler() 鍒嗙涓涓瓨鍦ㄧ殑浜嬩欢澶勭悊绋嬪簭銆 CComponent
disableBehavior() 绂佺敤涓涓檮鍔犺涓恒 CComponent
disableBehaviors() 绂佺敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
enableBehavior() 鍚敤涓涓檮鍔犺涓恒 CComponent
enableBehaviors() 鍚敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
endCache() Ends fragment caching. CBaseController
endClip() Ends recording a clip. CBaseController
endContent() Ends the rendering of content. CBaseController
endWidget() Ends the execution of the named widget. CBaseController
evaluateExpression() 璁$畻涓涓狿HP琛ㄨ揪寮忥紝鎴栨牴鎹粍浠朵笂涓嬫枃鎵ц鍥炶皟銆 CComponent
getController() 杩斿洖姝ゅ井浠舵墍灞炵殑鎺у埗鍣ㄣ CWidget
getEventHandlers() 杩斿洖涓涓簨浠剁殑闄勫姞澶勭悊绋嬪簭鍒楄〃銆 CComponent
getId() 杩斿洖姝ゅ井浠剁殑ID銆傚鏋滈渶瑕佺殑璇濓紝灏嗙敓浜т竴涓柊鐨処D骞跺皢鍏惰繑鍥炪 CWidget
getOwner() 杩斿洖姝ゅ井浠剁殑鎵鏈夎呮垨鍒涘缓鑰呫 CWidget
getViewFile() 鏍规嵁瑙嗗浘鍚嶆煡鎵捐鍥炬枃浠躲 CWidget
getViewPath() 杩斿洖鍖呭惈姝ゅ井浠舵墍闇鐨勮鍥炬枃浠剁殑璺緞銆 CWidget
hasEvent() 纭畾涓涓簨浠舵槸鍚﹀畾涔夈 CComponent
hasEventHandler() 妫鏌ヤ簨浠舵槸鍚︽湁闄勫姞鐨勫鐞嗙▼搴忋 CComponent
hasProperty() 纭畾灞炴ф槸鍚﹁瀹氫箟銆 CComponent
init() 鍒濆鍖栨寰欢銆 CWidget
raiseEvent() 鍙戣捣涓涓簨浠躲 CComponent
render() 娓叉煋涓涓鍥俱 CWidget
renderFile() Renders a view file. CBaseController
renderInternal() Renders a view file. CBaseController
run() 杩愯姝ゅ井浠躲 CWidget
setId() 璁剧疆姝ゅ井浠剁殑ID銆 CWidget
widget() Creates a widget and executes it. CBaseController

鍙椾繚鎶ゆ柟娉

闅愯棌缁ф壙鏂规硶

鏂规硶鎻忚堪瀹氫箟鍦
hasModel() 纭畾姝ゅ皬鐗╀欢鏄惁涓庝竴涓暟鎹ā鍨嬬浉鍏宠仈銆 CInputWidget
resolveNameID() CInputWidget

灞炴ц缁

attribute 灞炴
public string $attribute;

the 涓庢灏忕墿浠剁浉鍏宠仈鐨勫睘鎬с 杩欎釜鍚嶅瓧鍙互鍖呭惈鏂规嫭鍙 (e.g. 'name[1]') 鐢ㄦ潵鏀堕泦琛ㄦ牸寮忚緭鍏ャ

htmlOptions 灞炴
public array $htmlOptions;

娓叉煋杈撳叆鏍囩鏃堕檮鍔犵殑HTML閫夐」

model 灞炴
public CModel $model;

涓庢灏忕墿浠剁浉鍏宠仈鐨勬暟鎹ā鍨嬨

name 灞炴
public string $name;

杈撳叆鎺т欢鐨勫悕瀛椼傚鏋model娌℃湁璁剧疆锛屽垯蹇呴』璁剧疆姝ゅ睘鎬с

value 灞炴
public string $value;

杈撳叆鎺т欢鐨勫

鏂规硶璇︾粏

hasModel() 鏂规硶
protected boolean hasModel()
{return} boolean 姝ゅ皬鐗╀欢鏄惁涓庝竴涓暟鎹ā鍨嬬浉鍏宠仈銆
婧愮爜锛 framework/web/widgets/CInputWidget.php#77 (鏄剧ず)
protected function hasModel()
{
    return 
$this->model instanceof CModel && $this->attribute!==null;
}

resolveNameID() 鏂规硶
protected array resolveNameID()
{return} array 杈撳叆鎺т欢鐨勫悕瀛楀拰ID銆
婧愮爜锛 framework/web/widgets/CInputWidget.php#52 (鏄剧ず)
protected function resolveNameID()
{
    if(
$this->name!==null)
        
$name=$this->name;
    else if(isset(
$this->htmlOptions['name']))
        
$name=$this->htmlOptions['name'];
    else if(
$this->hasModel())
        
$name=CHtml::activeName($this->model,$this->attribute);
    else
        throw new 
CException(Yii::t('yii','{class} must specify "model" and "attribute" or "name" property values.',array('{class}'=>get_class($this))));

    if((
$id=$this->getId(false))===null)
    {
        if(isset(
$this->htmlOptions['id']))
            
$id=$this->htmlOptions['id'];
        else
            
$id=CHtml::getIdByName($name);
    }

    return array(
$name,$id);
}

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