public function testDefaultValue() { $array = array("key" => "val"); $this->stub->defaultValue($array, "key2", "val2"); $this->assertArrayHasKey("key2", $array); $this->assertEquals("val2", $array["key2"]); }
/** * @see parent::getFormHtmlElement() */ function getFormHtmlElement($object, $params, $value, $className) { $maxLength = 10; CMbArray::defaultValue($params, "size", $maxLength); CMbArray::defaultValue($params, "maxlength", $maxLength); return $this->getFormElementText($object, $params, $value, $className); }
/** * @see parent::getFormHtmlElement() */ function getFormHtmlElement($object, $params, $value, $className) { $form = CMbArray::extract($params, "form"); $increment = CMbArray::extract($params, "increment"); $showPlus = CMbArray::extract($params, "showPlus"); $fraction = CMbArray::extract($params, "fraction"); $showFraction = CMbArray::extract($params, "showFraction"); $deferEvent = CMbArray::extract($params, "deferEvent"); $bigButtons = CMbArray::extract($params, "bigButtons"); $readonly = CMbArray::get($params, "readonly"); $field = CMbString::htmlSpecialChars($this->fieldName); $min = CMbArray::extract($params, "min"); if ($min === null) { $min = CMbFieldSpec::checkNumeric($this->min, false); } $max = CMbArray::extract($params, "max"); if ($max === null) { $max = CMbFieldSpec::checkNumeric($this->max, false); } $new_value = CMbArray::extract($params, "value"); if ($new_value !== null) { $value = $new_value; } $decimals = CMbArray::extract($params, "decimals", $this->decimals); if ($decimals == null) { $decimals = isset($this->precise) ? 4 : 2; } $step = CMbArray::extract($params, "step"); $step = CMbFieldSpec::checkNumeric($step, false); CMbArray::defaultValue($params, "size", 4); if ($form && $increment && !$readonly) { $sHtml = $this->getFormElementText($object, $params, ($value >= 0 && $showPlus ? '+' : '') . ($value == 0 && $showPlus ? '0' : $value), $className, "number"); $sHtml .= ' <script type="text/javascript"> Main.add(function(){ var element = $(document.forms["' . $form . '"]["' . $field . '"]); if ($(element.form).isReadonly()) return; element.addSpinner({'; if ($step) { $sHtml .= "step: {$step},"; } if ($decimals) { $sHtml .= "decimals: {$decimals},"; } if ($this->pos) { $sHtml .= "min: 0,"; } elseif (isset($min)) { $sHtml .= "min: {$min},"; } if (isset($max)) { $sHtml .= "max: {$max},"; } if ($deferEvent) { $sHtml .= "deferEvent: true,"; } if ($bigButtons) { $sHtml .= "bigButtons: true,"; } if ($showPlus) { $sHtml .= "showPlus: true,"; } if ($fraction) { $sHtml .= "fraction: true,"; } if ($showFraction) { $sHtml .= "showFraction: true,"; } $sHtml .= '_:0 // IE rules }); }); </script>'; } else { $sHtml = $this->getFormElementText($object, $params, $value, $className, "number"); } return $sHtml; }
/** * @see parent::getFormHtmlElement() */ function getFormHtmlElement($object, $params, $value, $className) { $maxLength = CValue::first($this->length, $this->maxLength, 255); CMbArray::defaultValue($params, "size", min($maxLength, 25)); CMbArray::defaultValue($params, "maxlength", $maxLength); return $this->getFormElementText($object, $params, $value, $className); }
/** * @see parent::getFormHtmlElement() */ function getFormHtmlElement($object, $params, $value, $className) { CMbArray::defaultValue($params, "size", 6); return parent::getFormHtmlElement($object, $params, $value, $className) . CAppUI::conf("currency_symbol"); }
/** * @param array $params Template params: * - options : array of objects with IDs * - choose : string alternative for Choose default option * - size : interger for size of text input * @see classes/CMbFieldSpec#getFormHtmlElement($object, $params, $value, $className) * * @return string */ function getFormHtmlElement($object, $params, $value, $className) { if ($options = CMbArray::extract($params, "options")) { $field = CMbString::htmlSpecialChars($this->fieldName); $className = CMbString::htmlSpecialChars(trim("{$className} {$this->prop}")); $extra = CMbArray::makeXmlAttributes($params); $choose = CMbArray::extract($params, "choose", "Choose"); $choose = CAppUI::tr($choose); $html = "\n<select name=\"{$field}\" class=\"{$className}\" {$extra}>"; $html .= "\n<option value=\"\">— {$choose}</option>"; foreach ($options as $_option) { $selected = $value == $_option->_id ? "selected=\"selected\"" : ""; $html .= "\n<option value=\"{$_option->_id}\" {$selected}>{$_option->_view}</option>"; } $html .= "\n</select>"; return $html; } CMbArray::defaultValue($params, "size", 25); return $this->getFormElementText($object, $params, $value, $className); }
/** * @see parent::getFormHtmlElement() */ function getFormHtmlElement($object, $params, $value, $className) { CMbArray::defaultValue($params, "size", 6); return parent::getFormHtmlElement($object, $params, $value, $className) . "%"; }