Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • ActionActiveForm
  • ActionActiveFormBase
  • CActiveForm
  • CalendarEventActiveForm
  • CallActiveForm
  • CClipWidget
  • CContentDecorator
  • CFilterWidget
  • CFlexWidget
  • CHtmlPurifier
  • CInputWidget
  • CMarkdown
  • CMaskedTextField
  • CMultiFileUpload
  • COutputCache
  • COutputProcessor
  • CStarRating
  • CTabView
  • CTextHighlighter
  • CTreeView
  • CWidget
  • EventActiveForm
  • MobileActiveForm
  • NoteActiveForm
  • TimeActiveForm
  • X2ActiveForm
  • X2StarRating
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * CInputWidget class file.
 4:  *
 5:  * @author Qiang Xue <qiang.xue@gmail.com>
 6:  * @link http://www.yiiframework.com/
 7:  * @copyright 2008-2013 Yii Software LLC
 8:  * @license http://www.yiiframework.com/license/
 9:  */
10: 
11: /**
12:  * CInputWidget is the base class for widgets that collect user inputs.
13:  *
14:  * CInputWidget declares properties common among input widgets. An input widget
15:  * can be associated with a data model and an attribute, or a name and a value.
16:  * If the former, the name and the value will be generated automatically.
17:  * Child classes may use {@link resolveNameID} and {@link hasModel}.
18:  *
19:  * @author Qiang Xue <qiang.xue@gmail.com>
20:  * @package system.web.widgets
21:  * @since 1.0
22:  */
23: abstract class CInputWidget extends CWidget
24: {
25:     /**
26:      * @var CModel the data model associated with this widget.
27:      */
28:     public $model;
29:     /**
30:      * @var string the attribute associated with this widget.
31:      * The name can contain square brackets (e.g. 'name[1]') which is used to collect tabular data input.
32:      */
33:     public $attribute;
34:     /**
35:      * @var string the input name. This must be set if {@link model} is not set.
36:      */
37:     public $name;
38:     /**
39:      * @var string the input value
40:      */
41:     public $value;
42:     /**
43:      * @var array additional HTML options to be rendered in the input tag
44:      */
45:     public $htmlOptions=array();
46: 
47: 
48:     /**
49:      * @return array the name and the ID of the input.
50:      * @throws CException in case input name and ID cannot be resolved.
51:      */
52:     protected function resolveNameID()
53:     {
54:         if($this->name!==null)
55:             $name=$this->name;
56:         elseif(isset($this->htmlOptions['name']))
57:             $name=$this->htmlOptions['name'];
58:         elseif($this->hasModel())
59:             $name=CHtml::activeName($this->model,$this->attribute);
60:         else
61:             throw new CException(Yii::t('yii','{class} must specify "model" and "attribute" or "name" property values.',array('{class}'=>get_class($this))));
62: 
63:         if(($id=$this->getId(false))===null)
64:         {
65:             if(isset($this->htmlOptions['id']))
66:                 $id=$this->htmlOptions['id'];
67:             else
68:                 $id=CHtml::getIdByName($name);
69:         }
70: 
71:         return array($name,$id);
72:     }
73: 
74:     /**
75:      * @return boolean whether this widget is associated with a data model.
76:      */
77:     protected function hasModel()
78:     {
79:         return $this->model instanceof CModel && $this->attribute!==null;
80:     }
81: }
API documentation generated by ApiGen 2.8.0