本文整理汇总了PHP中TbHtml::getOption方法的典型用法代码示例。如果您正苦于以下问题:PHP TbHtml::getOption方法的具体用法?PHP TbHtml::getOption怎么用?PHP TbHtml::getOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TbHtml
的用法示例。
在下文中一共展示了TbHtml::getOption方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: error
/**
* Displays the first validation error for a model attribute.
* @param CModel $model the data model
* @param string $attribute the attribute name
* @param array $htmlOptions additional HTML attributes to be rendered in the container div tag.
* @param boolean $enableAjaxValidation whether to enable AJAX validation for the specified attribute.
* @param boolean $enableClientValidation whether to enable client-side validation for the specified attribute.
* @return string the validation result (error display or success message).
*/
public function error($model, $attribute, $htmlOptions = array(), $enableAjaxValidation = true, $enableClientValidation = true)
{
if (!$this->enableAjaxValidation) {
$enableAjaxValidation = false;
}
if (!$this->enableClientValidation) {
$enableClientValidation = false;
}
if (!$enableAjaxValidation && !$enableClientValidation) {
return TbHtml::error($model, $attribute, $htmlOptions);
}
$id = CHtml::activeId($model, $attribute);
$inputID = TbHtml::getOption('inputID', $htmlOptions, $id);
unset($htmlOptions['inputID']);
$htmlOptions = TbHtml::defaultOption('id', $inputID . '_em_', $htmlOptions);
$option = array('id' => $id, 'inputID' => $inputID, 'errorID' => $htmlOptions['id'], 'model' => get_class($model), 'name' => $attribute, 'enableAjaxValidation' => $enableAjaxValidation, 'inputContainer' => 'div.control-group');
$optionNames = array('validationDelay', 'validateOnChange', 'validateOnType', 'hideErrorMessage', 'inputContainer', 'errorCssClass', 'successCssClass', 'validatingCssClass', 'beforeValidateAttribute', 'afterValidateAttribute');
foreach ($optionNames as $name) {
if (isset($htmlOptions[$name])) {
$option[$name] = TbHtml::popOption($name, $htmlOptions);
}
}
if ($model instanceof CActiveRecord && !$model->isNewRecord) {
$option['status'] = 1;
}
if ($enableClientValidation) {
$validators = TbHtml::getOption('clientValidation', $htmlOptions, array());
$attributeName = $attribute;
if (($pos = strrpos($attribute, ']')) !== false && $pos !== strlen($attribute) - 1) {
// e.g. [a]name
$attributeName = substr($attribute, $pos + 1);
}
foreach ($model->getValidators($attributeName) as $validator) {
if ($validator->enableClientValidation) {
if (($js = $validator->clientValidateAttribute($model, $attributeName)) != '') {
$validators[] = $js;
}
}
}
if ($validators !== array()) {
$option['clientValidation'] = "js:function(value, messages, attribute) {\n" . implode("\n", $validators) . "\n}";
}
}
$html = TbHtml::error($model, $attribute, $htmlOptions);
if ($html === '') {
$htmlOptions['type'] = $this->helpType;
$htmlOptions = TbHtml::addStyles('display:none', $htmlOptions);
$html = TbHtml::help('', $htmlOptions);
}
$this->attributes[$inputID] = $option;
return $html;
}
示例2: registerClientScript
/**
* Register required scripts.
*/
public function registerClientScript()
{
/** @var TbApi $api */
$selector = '#' . TbHtml::getOption('id', $this->htmlOptions, $this->getId());
$this->registerPlugin(TbApi::PLUGIN_TYPEAHEAD, $selector, $this->pluginOptions);
}
示例3: normalizeTabs
/**
* Normalizes the tab configuration.
* @param array $tabs a reference to the tabs tab configuration.
*/
protected function normalizeTabs($tabs)
{
$controller = $this->getController();
if (isset($controller)) {
foreach ($tabs as &$tabOptions) {
$items = TbHtml::getOption('items', $tabOptions, array());
if (!empty($items)) {
$tabOptions['items'] = $this->normalizeTabs($items);
} else {
if (isset($tabOptions['view'])) {
$view = TbHtml::popOption('view', $tabOptions);
if ($controller->getViewFile($view) !== false) {
$tabOptions['content'] = $controller->renderPartial($view, $this->viewData, true);
}
}
}
}
}
return $tabs;
}
示例4: normalizeTabs
/**
* Normalizes the tab configuration.
* @param array $tabs the tab configuration
* @param array $panes a reference to the panes array
* @param integer $i the current index
* @return array the items
*/
protected function normalizeTabs($tabs, &$panes, &$i = 0)
{
$id = TbHtml::getOption('id', $this->htmlOptions, $this->getId());
$items = array();
//Check if has an active item
$hasActiveItem = false;
foreach ($tabs as $tab) {
if ($hasActiveItem = TbHtml::getOption('active', $tab, false) === true) {
break;
}
}
foreach ($tabs as $tab) {
$item = $tab;
if (isset($item['visible']) && $item['visible'] === false) {
continue;
}
// if no tab should be active, activate first
if (!$hasActiveItem && $i == 0) {
$item['active'] = true;
}
// set the label to the title if any
if (isset($item['title'])) {
$item['label'] = TbHtml::defaultOption('label', TbHtml::popOption('title', $item), $item);
}
$item = TbHtml::defaultOption('itemOptions', array(), $item);
if (isset($tab['items'])) {
$item['linkOptions']['data-toggle'] = 'dropdown';
$item['items'] = $this->normalizeTabs($item['items'], $panes, $i);
} else {
$item['linkOptions']['data-toggle'] = 'tab';
$item = TbHtml::defaultOption('id', $id . '_tab_' . ($i + 1), $item);
$item['url'] = '#' . $item['id'];
// no content and we have a view?
if (!isset($item['content']) && isset($item['view'])) {
$view = TbHtml::popOption('view', $item, '');
$data = TbHtml::popOption('data', $item, array());
if (is_array($this->viewData)) {
$data = TbHtml::mergeOptions($this->viewData, $data);
}
$process = TbHtml::popOption('processOutput', $item, false);
$item['content'] = !empty($view) ? $this->getController()->renderPartial($view, $data, true, $process) : '';
}
$content = TbHtml::popOption('content', $item, '');
$paneOptions = TbHtml::popOption('paneOptions', $item, array());
$paneOptions['id'] = TbHtml::popOption('id', $item);
$classes = array('tab-pane fade');
if (isset($item['active']) && $item['active']) {
$classes[] = 'active in';
}
$paneOptions = TbHtml::addClassName(implode(' ', $classes), $paneOptions);
$panes[] = CHtml::tag('div', $paneOptions, $content);
$i++;
// increment the tab-index
}
$items[] = $item;
}
return $items;
}
示例5: registerClientScript
/**
* Register required scripts.
*/
public function registerClientScript()
{
/** @var TbApi $api */
$api = Yii::app()->getComponent('bootstrap');
$selector = '#' . TbHtml::getOption('id', $this->htmlOptions, $this->getId());
$api->registerPlugin(TbApi::PLUGIN_TYPEAHEAD, $selector, $this->pluginOptions);
}