File indexing completed on 2025-03-02 05:29:19
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Dojo 0017 * @subpackage Form_Element 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 */ 0021 0022 /** Zend_Dojo_Form_Element_DijitMulti */ 0023 // require_once 'Zend/Dojo/Form/Element/DijitMulti.php'; 0024 0025 /** 0026 * ComboBox dijit 0027 * 0028 * @uses Zend_Dojo_Form_Element_DijitMulti 0029 * @package Zend_Dojo 0030 * @subpackage Form_Element 0031 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0032 * @license http://framework.zend.com/license/new-bsd New BSD License 0033 * @version $Id$ 0034 */ 0035 class Zend_Dojo_Form_Element_ComboBox extends Zend_Dojo_Form_Element_DijitMulti 0036 { 0037 /** 0038 * Use ComboBox dijit view helper 0039 * @var string 0040 */ 0041 public $helper = 'ComboBox'; 0042 0043 /** 0044 * Flag: autoregister inArray validator? 0045 * @var bool 0046 */ 0047 protected $_registerInArrayValidator = false; 0048 0049 /** 0050 * Get datastore information 0051 * 0052 * @return array 0053 */ 0054 public function getStoreInfo() 0055 { 0056 if (!$this->hasDijitParam('store')) { 0057 $this->dijitParams['store'] = array(); 0058 } 0059 return $this->dijitParams['store']; 0060 } 0061 0062 /** 0063 * Set datastore identifier 0064 * 0065 * @param string $identifier 0066 * @return Zend_Dojo_Form_Element_ComboBox 0067 */ 0068 public function setStoreId($identifier) 0069 { 0070 $store = $this->getStoreInfo(); 0071 $store['store'] = (string) $identifier; 0072 $this->setDijitParam('store', $store); 0073 return $this; 0074 } 0075 0076 /** 0077 * Get datastore identifier 0078 * 0079 * @return string|null 0080 */ 0081 public function getStoreId() 0082 { 0083 $store = $this->getStoreInfo(); 0084 if (array_key_exists('store', $store)) { 0085 return $store['store']; 0086 } 0087 return null; 0088 } 0089 0090 /** 0091 * Set datastore dijit type 0092 * 0093 * @param string $dojoType 0094 * @return Zend_Dojo_Form_Element_ComboBox 0095 */ 0096 public function setStoreType($dojoType) 0097 { 0098 $store = $this->getStoreInfo(); 0099 $store['type'] = (string) $dojoType; 0100 $this->setDijitParam('store', $store); 0101 return $this; 0102 } 0103 0104 /** 0105 * Get datastore dijit type 0106 * 0107 * @return string|null 0108 */ 0109 public function getStoreType() 0110 { 0111 $store = $this->getStoreInfo(); 0112 if (array_key_exists('type', $store)) { 0113 return $store['type']; 0114 } 0115 return null; 0116 } 0117 0118 /** 0119 * Set datastore parameters 0120 * 0121 * @param array $params 0122 * @return Zend_Dojo_Form_Element_ComboBox 0123 */ 0124 public function setStoreParams(array $params) 0125 { 0126 $store = $this->getStoreInfo(); 0127 $store['params'] = $params; 0128 $this->setDijitParam('store', $store); 0129 return $this; 0130 } 0131 0132 /** 0133 * Get datastore params 0134 * 0135 * @return array 0136 */ 0137 public function getStoreParams() 0138 { 0139 $store = $this->getStoreInfo(); 0140 if (array_key_exists('params', $store)) { 0141 return $store['params']; 0142 } 0143 return array(); 0144 } 0145 0146 /** 0147 * Set autocomplete flag 0148 * 0149 * @param bool $flag 0150 * @return Zend_Dojo_Form_Element_ComboBox 0151 */ 0152 public function setAutocomplete($flag) 0153 { 0154 $this->setDijitParam('autocomplete', (bool) $flag); 0155 return $this; 0156 } 0157 0158 /** 0159 * Get autocomplete flag 0160 * 0161 * @return bool 0162 */ 0163 public function getAutocomplete() 0164 { 0165 if (!$this->hasDijitParam('autocomplete')) { 0166 return false; 0167 } 0168 return $this->getDijitParam('autocomplete'); 0169 } 0170 0171 /** 0172 * Is the value valid? 0173 * 0174 * @param string $value 0175 * @param mixed $context 0176 * @return bool 0177 */ 0178 public function isValid($value, $context = null) 0179 { 0180 $storeInfo = $this->getStoreInfo(); 0181 if (!empty($storeInfo)) { 0182 $this->setRegisterInArrayValidator(false); 0183 } 0184 return parent::isValid($value, $context); 0185 } 0186 }