QControlBase::__construct PHP Метод

__construct() публичный Метод

public __construct ( $objParentObject, $strControlId = null )
    public function __construct($objParentObject, $strControlId = null)
    {
        if ($objParentObject instanceof QForm) {
            $this->objForm = $objParentObject;
        } else {
            if ($objParentObject instanceof QControl) {
                $this->objParentControl = $objParentObject;
                //				$this->objParentControl->blnModified = true;
                $this->objForm = $objParentObject->Form;
            } else {
                throw new QCallerException('ParentObject must be either a QForm or QControl object');
            }
        }
        if (strlen($strControlId) == 0) {
            $this->strControlId = $this->objForm->GenerateControlId();
        } else {
            // Verify ControlId is only AlphaNumeric Characters
            if (ctype_alnum($strControlId)) {
                $this->strControlId = $strControlId;
            } else {
                throw new QCallerException('ControlIDs must be only alphanumeric chacters: ' . $strControlId);
            }
        }
        try {
            $this->objForm->AddControl($this);
            if ($this->objParentControl) {
                $this->objParentControl->AddChildControl($this);
            }
        } catch (QCallerException $objExc) {
            $objExc->IncrementOffset();
            throw $objExc;
        }
    }

Usage Example

Пример #1
0
 /**
  * Note that the constructor cannot be put into the trait, because it will cause a conflict.
  * @param \QControl|\QControlBase|\QForm $objParent
  * @param null $strControlId
  */
 public function __construct($objParent, $strControlId = null)
 {
     parent::__construct($objParent, $strControlId);
     Bootstrap::LoadJS($this);
     /*
     
     if ($this instanceof \QTextBoxBase ||
     	$this instanceof \QListBox) {
     	$this->AddCssClass (Bootstrap::FormControl);
     }
     */
 }