本文整理匯總了PHP中rex_select::addOptgroup方法的典型用法代碼示例。如果您正苦於以下問題:PHP rex_select::addOptgroup方法的具體用法?PHP rex_select::addOptgroup怎麽用?PHP rex_select::addOptgroup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rex_select
的用法示例。
在下文中一共展示了rex_select::addOptgroup方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getOutput
protected function getOutput()
{
$id = $this->getArg('id', 0, true);
if (!in_array($this->getContext(), ['module', 'action']) || !is_numeric($id) || $id < 1 || $id > 20) {
return false;
}
$value = $this->getContextData()->getValue('value' . $id);
if ($this->hasArg('isset') && $this->getArg('isset')) {
return $value ? 'true' : 'false';
}
if ($this->hasArg('widget') && $this->getArg('widget')) {
if (!$this->environmentIs(self::ENV_INPUT)) {
return false;
}
$select = new rex_select();
if ($this->hasArg('multiple') && $this->getArg('options')) {
$select->setName('REX_INPUT_VALUE[' . $id . '][]');
$select->setMultiple();
$select->setSelected(rex_var::toArray($value));
} else {
$select->setName('REX_INPUT_VALUE[' . $id . ']');
$select->setSelected($value);
}
if ($this->hasArg('options') && $this->getArg('options')) {
$options = $this->getArg('options');
if (rex_sql::getQueryType($options) == 'SELECT') {
$select->addSqlOptions($options);
} else {
$groups = explode('|', $options);
if (count($groups)) {
foreach ($groups as $group) {
$parseGroup = explode(':', $group);
$groupOptions = $parseGroup[0];
if (count($parseGroup) == 2) {
$select->addOptgroup($parseGroup[0]);
$groupOptions = $parseGroup[1];
}
if (rex_sql::getQueryType($groupOptions) == 'SELECT') {
$select->addSqlOptions($groupOptions);
} else {
$groupOptions = explode(',', $groupOptions);
if (count($groupOptions)) {
foreach ($groupOptions as $groupOption) {
$optionPair = explode('=', $groupOption);
if (count($optionPair) == 1) {
$select->addOption($optionPair[0], $optionPair[0]);
} elseif (count($optionPair) == 2) {
$select->addOption($optionPair[0], $optionPair[1]);
}
}
}
}
}
}
}
}
$widget = '<div class="rex-select-style">' . $select->get() . '</div>';
if ($this->hasArg('output') && $this->getArg('output')) {
$label = $this->hasArg('label') ? $this->getArg('label') : '';
$widget = Dao::getForm($widget, $label, $this->getArg('output'));
}
return self::quote($widget);
}
return self::quote(htmlspecialchars($value));
}