本文整理汇总了PHP中WebPage::GetRadioButtons方法的典型用法代码示例。如果您正苦于以下问题:PHP WebPage::GetRadioButtons方法的具体用法?PHP WebPage::GetRadioButtons怎么用?PHP WebPage::GetRadioButtons使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebPage
的用法示例。
在下文中一共展示了WebPage::GetRadioButtons方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Display
/**
* Get the HTML fragment corresponding to the ext key editing widget
* @param WebPage $oP The web page used for all the output
* @param Hash $aArgs Extra context arguments
* @return string The HTML fragment to be inserted into the page
*/
public function Display(WebPage $oPage, $iMaxComboLength, $bAllowTargetCreation, $sTitle, $oAllowedValues, $value, $iInputId, $bMandatory, $sFieldName, $sFormPrefix = '', $aArgs = array(), $bSearchMode = null, $sDisplayStyle = 'select', $bSearchMultiple = true)
{
if (!is_null($bSearchMode)) {
$this->bSearchMode = $bSearchMode;
}
$sTitle = addslashes($sTitle);
$oPage->add_linked_script('../js/extkeywidget.js');
$oPage->add_linked_script('../js/forms-json-utils.js');
$bCreate = !$this->bSearchMode && !MetaModel::IsAbstract($this->sTargetClass) && (UserRights::IsActionAllowed($this->sTargetClass, UR_ACTION_BULK_MODIFY) && $bAllowTargetCreation);
$bExtensions = true;
$sMessage = Dict::S('UI:Message:EmptyList:UseSearchForm');
$sAttrFieldPrefix = $this->bSearchMode ? '' : 'attr_';
$sHTMLValue = "<span style=\"white-space:nowrap\">";
// no wrap
$sFilter = addslashes($oAllowedValues->GetFilter()->ToOQL());
if ($this->bSearchMode) {
$sWizHelper = 'null';
$sWizHelperJSON = "''";
$sJSSearchMode = 'true';
} else {
if (isset($aArgs['wizHelper'])) {
$sWizHelper = $aArgs['wizHelper'];
} else {
$sWizHelper = 'oWizardHelper' . $sFormPrefix;
}
$sWizHelperJSON = $sWizHelper . '.UpdateWizardToJSON()';
$sJSSearchMode = 'false';
}
if (is_null($oAllowedValues)) {
throw new Exception('Implementation: null value for allowed values definition');
} elseif ($oAllowedValues->Count() < $iMaxComboLength) {
// Discrete list of values, use a SELECT or RADIO buttons depending on the config
switch ($sDisplayStyle) {
case 'radio':
case 'radio_horizontal':
case 'radio_vertical':
$sValidationField = "<span id=\"v_{$this->iId}\"></span>";
$sHTMLValue = '';
$bVertical = $sDisplayStyle != 'radio_horizontal';
$bExtensions = false;
$oAllowedValues->Rewind();
$aAllowedValues = array();
while ($oObj = $oAllowedValues->Fetch()) {
$aAllowedValues[$oObj->GetKey()] = $oObj->GetName();
}
$sHTMLValue = $oPage->GetRadioButtons($aAllowedValues, $value, $this->iId, "{$sAttrFieldPrefix}{$sFieldName}", $bMandatory, $bVertical, $sValidationField);
$aEventsList[] = 'change';
break;
case 'select':
case 'list':
default:
$sSelectMode = 'true';
$sHelpText = '';
//$this->oAttDef->GetHelpOnEdition();
if ($this->bSearchMode) {
if ($bSearchMultiple) {
$sHTMLValue = "<select class=\"multiselect\" multiple title=\"{$sHelpText}\" name=\"{$sAttrFieldPrefix}{$sFieldName}[]\" id=\"{$this->iId}\">\n";
} else {
$sHTMLValue = "<select title=\"{$sHelpText}\" name=\"{$sAttrFieldPrefix}{$sFieldName}\" id=\"{$this->iId}\">\n";
$sDisplayValue = isset($aArgs['sDefaultValue']) ? $aArgs['sDefaultValue'] : Dict::S('UI:SearchValue:Any');
$sHTMLValue .= "<option value=\"\">{$sDisplayValue}</option>\n";
}
} else {
$sHTMLValue = "<select title=\"{$sHelpText}\" name=\"{$sAttrFieldPrefix}{$sFieldName}\" id=\"{$this->iId}\">\n";
$sHTMLValue .= "<option value=\"\">" . Dict::S('UI:SelectOne') . "</option>\n";
}
$oAllowedValues->Rewind();
while ($oObj = $oAllowedValues->Fetch()) {
$key = $oObj->GetKey();
$display_value = $oObj->GetName();
if ($oAllowedValues->Count() == 1 && $bMandatory == 'true') {
// When there is only once choice, select it by default
$sSelected = ' selected';
} else {
$sSelected = is_array($value) && in_array($key, $value) || $value == $key ? ' selected' : '';
}
$sHTMLValue .= "<option value=\"{$key}\"{$sSelected}>{$display_value}</option>\n";
}
$sHTMLValue .= "</select>\n";
if ($this->bSearchMode && $bSearchMultiple) {
$aOptions = array('header' => true, 'checkAllText' => Dict::S('UI:SearchValue:CheckAll'), 'uncheckAllText' => Dict::S('UI:SearchValue:UncheckAll'), 'noneSelectedText' => Dict::S('UI:SearchValue:Any'), 'selectedText' => Dict::S('UI:SearchValue:NbSelected'), 'selectedList' => 1);
$sJSOptions = json_encode($aOptions);
$oPage->add_ready_script("\$('.multiselect').multiselect({$sJSOptions});");
}
$oPage->add_ready_script(<<<EOF
\t\toACWidget_{$this->iId} = new ExtKeyWidget('{$this->iId}', '{$this->sTargetClass}', '{$sFilter}', '{$sTitle}', true, {$sWizHelper}, '{$this->sAttCode}', {$sJSSearchMode});
\t\toACWidget_{$this->iId}.emptyHtml = "<div style=\\"background: #fff; border:0; text-align:center; vertical-align:middle;\\"><p>{$sMessage}</p></div>";
\t\t\$('#{$this->iId}').bind('update', function() { oACWidget_{$this->iId}.Update(); } );
\t\t\$('#{$this->iId}').bind('change', function() { \$(this).trigger('extkeychange') } );
EOF
);
}
// Switch
//.........这里部分代码省略.........