/** * PHP __set Magic method * @param string $strName Property Name * @param string $mixValue Property Value * * @throws Exception|QInvalidCastException */ public function __set($strName, $mixValue) { switch ($strName) { case 'DataSource': // Assign data to a DataSource from within the data binder function only. // Data should be array items that at a minimum contain a 'value' and an 'id' // They can also contain a 'label', which will be displayed in the popup menu only if ($this->blnUseAjax) { $this->prepareAjaxList($mixValue); } else { $this->Source = $mixValue; } break; case 'SelectedId': // Set this at creation time to initialize the selected id. // This is also set by the javascript above to keep track of subsequent selections made by the user. try { $this->strSelectedId = QType::Cast($mixValue, QType::String); } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } break; case 'MustMatch': try { $this->blnMustMatch = QType::Cast($mixValue, QType::Boolean); $this->blnModified = true; // Be sure control gets redrawn } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } break; case 'Source': try { if (is_array($mixValue) && count($mixValue) > 0 && $mixValue[0] instanceof QListItem) { // figure out what item is selected foreach ($mixValue as $objItem) { if ($objItem->Selected) { $this->strSelectedId = $objItem->Value; $this->Text = $objItem->Name; } } } if ($this->MultipleValueDelimiter) { $strBody = 'response(jQuery.ui.autocomplete.filter(' . JavaScriptHelper::toJsObject($mixValue) . ', this.element.data("curTerm")(this.element.get(0))))'; $mixValue = new QJsClosure($strBody, array('request', 'response')); } // do parent action too parent::__set($strName, $mixValue); } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } break; case 'MultipleValueDelimiter': $a = $this->GetAllActions('QAutocomplete_SourceEvent'); if (!empty($a)) { throw new Exception('Must set MultipleValueDelimiter BEFORE calling SetDataBinder'); } try { $this->strMultipleValueDelimiter = QType::Cast($mixValue, QType::String); } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } break; case 'DisplayHtml': try { $this->blnDisplayHtml = QType::Cast($mixValue, QType::Boolean); } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } break; default: try { parent::__set($strName, $mixValue); } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } break; } }
/** * PHP __set Magic method * @param string $strName Property Name * @param string $mixValue Property Value * * @throws Exception|QInvalidCastException */ public function __set($strName, $mixValue) { switch ($strName) { case 'DataSource': // Assign data to a DataSource from within the data binder function only. // Data should be array items that at a minimum contain a 'value' and an 'id' // They can also contain a 'label', which will be displayed in the popup menu only if ($this->blnUseAjax) { $this->prepareAjaxList($mixValue); } else { $this->Source = $mixValue; } break; case "SelectedValue": // mirror list control // mirror list control case "Value": case 'SelectedId': // Set this at creation time to initialize the selected id. // This is also set by the javascript above to keep track of subsequent selections made by the user. try { if ($mixValue == 'null') { $this->strSelectedId = null; } else { $this->strSelectedId = QType::Cast($mixValue, QType::String); } } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } break; case 'Source': try { if (is_array($mixValue) && count($mixValue) > 0 && $mixValue[0] instanceof QListItem) { // figure out what item is selected foreach ($mixValue as $objItem) { if ($objItem->Selected) { $this->strSelectedId = $objItem->Value; $this->Text = $objItem->Name; } } } parent::__set($strName, $mixValue); } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } break; default: try { parent::__set($strName, $mixValue); } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } break; } }