Yii Framework v1.1.10 绫诲弬鑰

CFormElementCollection

system.web.form
缁ф壙 class CFormElementCollection » CMap » CComponent
瀹炵幇 Countable, ArrayAccess, Traversable, IteratorAggregate
婧愯嚜 1.1
鐗堟湰 $Id: CFormElementCollection.php 3054 2011-03-12 21:30:21Z qiang.xue $
婧愮爜 framework/web/form/CFormElementCollection.php
CFormElementCollection 瀹炵幇瀛樺偍琛ㄥ崟鍏冪礌鐨勯泦鍚堛

鍥犱负CFormElementCollection缁ф壙鑷CMap锛屾墍浠ュ畠鍙互鍚戜竴涓叧鑱旀暟缁勯偅鏍锋潵浣跨敤銆 渚嬪锛
$element=$collection['username'];
$collection['username']=array('type'=>'text', 'maxlength'=>128);
$collection['password']=new CFormInputElement(array('type'=>'password'),$form);
$collection[]='some string';


CFormElementCollection 鍙互瀛樺偍涓夌绫诲瀷鐨勫硷細 涓绉嶆槸閰嶇疆鏁扮粍锛屼竴绉嶆槸CFormElement瀵硅薄锛屼竴绉嶆槸瀛楃涓诧紝 姝e涓婇潰渚嬪瓙涓樉绀虹殑閭f牱锛屽湪鍐呴儴锛岃繖浜涘煎皢琚浆鎹负CFormElement瀵硅薄銆

鍏叡灞炴

闅愯棌缁ф壙灞炴

灞炴绫诲瀷鎻忚堪瀹氫箟鍦
count integer 杩斿洖map涓殑椤圭洰鏁般 CMap
iterator CMapIterator 杩斿洖閬嶅巻杩欎釜鍒楄〃鐨勯」鐩殑杩唬鍣ㄣ CMap
keys array 杩斿洖閿悕鍒楄〃 CMap
readOnly boolean 杩斿洖鍊艰鏄庤繖涓垪琛ㄦ槸鍚︿负鍙銆傞粯璁や负false銆 CMap

鍏叡鏂规硶

闅愯棌缁ф壙鏂规硶

鏂规硶鎻忚堪瀹氫箟鍦
__call() 濡傛灉绫讳腑娌℃湁璋冪殑鏂规硶鍚嶏紝鍒欒皟鐢ㄨ繖涓柟娉曘 CComponent
__construct() 鏋勯犳柟娉曘 CFormElementCollection
__get() 杩斿洖涓涓睘鎬у笺佷竴涓簨浠跺鐞嗙▼搴忓垪琛ㄦ垨涓涓涓哄悕绉般 CComponent
__isset() 妫鏌ヤ竴涓睘鎬ф槸鍚︿负null銆 CComponent
__set() 璁剧疆涓涓粍浠剁殑灞炴у笺 CComponent
__unset() 璁剧疆涓涓粍浠剁殑灞炴т负null銆 CComponent
add() 澧炲姞涓涓」鐩埌闆嗗悎銆 CFormElementCollection
asa() 杩斿洖杩欎釜鍚嶅瓧鐨勮涓哄璞° CComponent
attachBehavior() 闄勫姞涓涓涓哄埌缁勪欢銆 CComponent
attachBehaviors() 闄勫姞涓涓涓哄垪琛ㄥ埌缁勪欢銆 CComponent
attachEventHandler() 涓轰簨浠堕檮鍔犱竴涓簨浠跺鐞嗙▼搴忋 CComponent
canGetProperty() 纭畾灞炴ф槸鍚﹀彲璇汇 CComponent
canSetProperty() 纭畾灞炴ф槸鍚﹀彲鍐欍 CComponent
clear() 鍒犻櫎map涓墍鏈夐」鐩 CMap
contains() CMap
copyFrom() 灏嗚凯浠e櫒涓殑鏁版嵁澶嶅埗鍒癿ap銆 CMap
count() 杩斿洖map涓殑椤圭洰鏁般 CMap
detachBehavior() 浠庣粍浠朵腑鍒嗙涓涓涓恒 CComponent
detachBehaviors() 浠庣粍浠朵腑鍒嗙鎵鏈夎涓恒 CComponent
detachEventHandler() 鍒嗙涓涓瓨鍦ㄧ殑浜嬩欢澶勭悊绋嬪簭銆 CComponent
disableBehavior() 绂佺敤涓涓檮鍔犺涓恒 CComponent
disableBehaviors() 绂佺敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
enableBehavior() 鍚敤涓涓檮鍔犺涓恒 CComponent
enableBehaviors() 鍚敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
evaluateExpression() 璁$畻涓涓狿HP琛ㄨ揪寮忥紝鎴栨牴鎹粍浠朵笂涓嬫枃鎵ц鍥炶皟銆 CComponent
getCount() 杩斿洖map涓殑椤圭洰鏁般 CMap
getEventHandlers() 杩斿洖涓涓簨浠剁殑闄勫姞澶勭悊绋嬪簭鍒楄〃銆 CComponent
getIterator() 杩斿洖閬嶅巻杩欎釜鍒楄〃鐨勯」鐩殑杩唬鍣ㄣ CMap
getKeys() 杩斿洖杩斿洖閿悕鍒楄〃 CMap
getReadOnly() 杩斿洖杩斿洖鍊艰鏄庤繖涓垪琛ㄦ槸鍚︿负鍙銆傞粯璁や负false銆 CMap
hasEvent() 纭畾涓涓簨浠舵槸鍚﹀畾涔夈 CComponent
hasEventHandler() 妫鏌ヤ簨浠舵槸鍚︽湁闄勫姞鐨勫鐞嗙▼搴忋 CComponent
hasProperty() 纭畾灞炴ф槸鍚﹁瀹氫箟銆 CComponent
itemAt() 杩斿洖鎸囧畾浣嶇疆鐨勯」鐩 CMap
mergeArray() 閫掑綊鍚堝苟涓や釜鎴栧涓暟缁勩 CMap
mergeWith() 灏嗚凯浠e櫒鐨勬暟鎹暣鍚堝埌map銆 CMap
offsetExists() 杩斿洖鍊艰鏄庢寚瀹氫綅缃槸鍚﹀瓨鍦ㄥ厓绱犮 CMap
offsetGet() 杩斿洖鍊兼寚瀹氫綅缃殑鍏冪礌銆 CMap
offsetSet() 璁剧疆鎸囧畾浣嶇疆鐨勫厓绱犮 CMap
offsetUnset() 鍒犻櫎鎸囧畾浣嶇疆鐨勫厓绱犮 CMap
raiseEvent() 鍙戣捣涓涓簨浠躲 CComponent
remove() 鏍规嵁閿悕绉婚櫎鎸囧畾鐨勫厓绱犮 CFormElementCollection
toArray() CMap

鍙椾繚鎶ゆ柟娉

闅愯棌缁ф壙鏂规硶

鏂规硶鎻忚堪瀹氫箟鍦
setReadOnly() 璁剧疆璁剧疆杩欎釜鍒楄〃鏄惁涓哄彧璇 CMap

鏂规硶璇︾粏

__construct() 鏂规硶
public void __construct(CForm $form, boolean $forButtons=false)
$form CForm 鎷ユ湁杩欎釜闆嗗悎鐨勮〃鍗曞璞
$forButtons boolean 杩欎釜闆嗗悎鏄惁鐢ㄦ潵瀛樺偍鎸夐挳銆
婧愮爜锛 framework/web/form/CFormElementCollection.php#42 (鏄剧ず)
public function __construct($form,$forButtons=false)
{
    
parent::__construct();
    
$this->_form=$form;
    
$this->_forButtons=$forButtons;
}

鏋勯犳柟娉曘

add() 鏂规硶
public void add(mixed $key, mixed $value)
$key mixed 閿悕
$value mixed 閿
婧愮爜锛 framework/web/form/CFormElementCollection.php#58 (鏄剧ず)
public function add($key,$value)
{
    if(
is_array($value))
    {
        if(
is_string($key))
            
$value['name']=$key;

        if(
$this->_forButtons)
        {
            
$class=$this->_form->buttonElementClass;
            
$element=new $class($value,$this->_form);
        }
        else
        {
            if(!isset(
$value['type']))
                
$value['type']='text';
            if(
$value['type']==='string')
            {
                unset(
$value['type'],$value['name']);
                
$element=new CFormStringElement($value,$this->_form);
            }
            else if(!
strcasecmp(substr($value['type'],-4),'form'))    // a form
            
{
                
$class=$value['type']==='form' get_class($this->_form) : Yii::import($value['type']);
                
$element=new $class($value,null,$this->_form);
            }
            else
            {
                
$class=$this->_form->inputElementClass;
                
$element=new $class($value,$this->_form);
            }
        }
    }
    else if(
$value instanceof CFormElement)
    {
        if(
property_exists($value,'name') && is_string($key))
            
$value->name=$key;
        
$element=$value;
    }
    else
        
$element=new CFormStringElement(array('content'=>$value),$this->_form);
    
parent::add($key,$element);
    
$this->_form->addedElement($key,$element,$this->_forButtons);
}

澧炲姞涓涓」鐩埌闆嗗悎銆 杩欎釜鏂规硶閲嶅啓鐖剁被鐨勭殑鏂规硶 鏉ョ‘淇濆彧鏈夐厤缃暟缁勶紝瀛楃涓诧紝鎴CFormElement瀵硅薄 浼氳瀛樺偍鍒伴泦鍚堜腑銆

remove() 鏂规硶
public void remove(string $key)
$key string 灏嗚浠庨泦鍚堜腑绉婚櫎鐨勫厓绱犵殑閿悕銆
婧愮爜锛 framework/web/form/CFormElementCollection.php#107 (鏄剧ず)
public function remove($key)
{
    if((
$item=parent::remove($key))!==null)
        
$this->_form->removedElement($key,$item,$this->_forButtons);
}

鏍规嵁閿悕绉婚櫎鎸囧畾鐨勫厓绱犮

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