diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 3cdf07069..4f3c450e3 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -80,6 +80,35 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay public const ENUM_OBJECT_MODE_STIMULUS = 'stimulus'; /** @var string ENUM_OBJECT_MODE_PRINT */ public const ENUM_OBJECT_MODE_PRINT = 'print'; + + // N°3750 rendering used + /** @var string */ + public const ENUM_INPUT_TYPE_SINGLE_INPUT = 'single_input'; + /** @var string */ + public const ENUM_INPUT_TYPE_MULTIPLE_INPUTS = 'multiple_inputs'; + /** @var string */ + public const ENUM_INPUT_TYPE_TEXTAREA = 'textarea'; + /** @var string */ + public const ENUM_INPUT_TYPE_HTML_EDITOR = 'html_editor'; + /** @var string */ + public const ENUM_INPUT_TYPE_DOCUMENT = 'document'; + /** @var string */ + public const ENUM_INPUT_TYPE_IMAGE = 'image'; + /** @var string */ + public const ENUM_INPUT_TYPE_PASSWORD = 'password'; + /** @var string */ + public const ENUM_INPUT_TYPE_TAGSET = 'tagset'; + /** @var string */ + public const ENUM_INPUT_TYPE_RADIO = 'radio'; + /** @var string */ + public const ENUM_INPUT_TYPE_DROPDOWN_RAW = 'dropdown_raw'; + /** @var string */ + public const ENUM_INPUT_TYPE_DROPDOWN_DECORATED = 'dropdown_decorated'; // now with the JQuery Selectize plugin + /** @var string */ + public const ENUM_INPUT_TYPE_DROPDOWN_MULTIPLE_CHOICES = 'dropdown_multiple_choices'; + /** @var string */ + public const ENUM_INPUT_TYPE_AUTOCOMPLETE = 'autocomplete'; + /** * @var string DEFAULT_OBJECT_MODE * @since 3.0.0 @@ -854,6 +883,7 @@ EOF if ((!$oAttDef->IsLinkSet()) && (($iFlags & OPT_ATT_HIDDEN) == 0) && !($oAttDef instanceof AttributeDashboard)) { $sInputId = $this->m_iFormId.'_'.$sAttCode; if ($oAttDef->IsWritable()) { + $sInputType = ''; if (($sStateAttCode === $sAttCode) && (MetaModel::HasLifecycle($sClass))) { // State attribute is always read-only from the UI $sHTMLValue = $this->GetAsHTML($sAttCode); @@ -887,15 +917,15 @@ EOF // Attribute is read-only $sHTMLValue = "".$this->GetAsHTML($sAttCode).''; - } - else - { + } else { $sValue = $this->Get($sAttCode); $sDisplayValue = $this->GetEditValue($sAttCode); $aArgs = array('this' => $this, 'formPrefix' => $sPrefix); - $sHTMLValue = "".self::GetFormElementForField($oPage, $sClass, $sAttCode, - $oAttDef, $sValue, $sDisplayValue, $sInputId, '', $iFlags, - $aArgs).''; + $sHTMLValue = "".self::GetFormElementForField( + $oPage, $sClass, $sAttCode, $oAttDef, $sValue, + $sDisplayValue, $sInputId, '', $iFlags, $aArgs, + true, $sInputType + ).''; } $aFieldsMap[$sAttCode] = $sInputId; @@ -908,6 +938,7 @@ EOF 'label' => ''.$oAttDef->GetLabel().'', 'value' => $sHTMLValue, 'input_id' => $sInputId, + 'input_type' => $sInputType, 'comments' => $sComments, 'infos' => $sInfos, ); @@ -1748,6 +1779,7 @@ HTML return $oSearchForm->GetSearchForm($oPage, $oSet, $aExtraParams); } + /** * @param \WebPage $oPage * @param string $sClass @@ -1760,38 +1792,43 @@ HTML * @param int $iFlags * @param array $aArgs * @param bool $bPreserveCurrentValue Preserve the current value even if not allowed + * @param string $sInputType type of rendering used, see ENUM_INPUT_TYPE_* const * * @return string + * * @throws \ArchivedObjectException + * @throws \ConfigException * @throws \CoreException + * @throws \CoreUnexpectedValue * @throws \DictExceptionMissingString + * @throws \MySQLException + * @throws \OQLException + * @throws \ReflectionException + * @throws \Twig\Error\LoaderError + * @throws \Twig\Error\RuntimeError + * @throws \Twig\Error\SyntaxError */ - public static function GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $value = '', $sDisplayValue = '', $iId = '', $sNameSuffix = '', $iFlags = 0, $aArgs = array(), $bPreserveCurrentValue = true) + public static function GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $value = '', $sDisplayValue = '', $iId = '', $sNameSuffix = '', $iFlags = 0, $aArgs = array(), $bPreserveCurrentValue = true, &$sInputType = '') { $sFormPrefix = isset($aArgs['formPrefix']) ? $aArgs['formPrefix'] : ''; $sFieldPrefix = isset($aArgs['prefix']) ? $sFormPrefix.$aArgs['prefix'] : $sFormPrefix; - if ($sDisplayValue == '') - { + if ($sDisplayValue == '') { $sDisplayValue = $value; } - if (isset($aArgs[$sAttCode]) && empty($value)) - { + if (isset($aArgs[$sAttCode]) && empty($value)) { // default value passed by the context (either the app context of the operation) $value = $aArgs[$sAttCode]; } - if (!empty($iId)) - { + if (!empty($iId)) { $iInputId = $iId; - } - else { + } else { $iInputId = utils::GetUniqueId(); } $sHTMLValue = ''; - if (!$oAttDef->IsExternalField()) - { + if (!$oAttDef->IsExternalField()) { $bMandatory = 'false'; if ((!$oAttDef->IsNullAllowed()) || ($iFlags & OPT_ATT_MANDATORY)) { $bMandatory = 'true'; @@ -1813,6 +1850,7 @@ HTML switch ($oAttDef->GetEditClass()) { case 'Date': + $sInputType = self::ENUM_INPUT_TYPE_SINGLE_INPUT; $aEventsList[] = 'validate'; $aEventsList[] = 'keyup'; $aEventsList[] = 'change'; @@ -1824,6 +1862,7 @@ HTML break; case 'DateTime': + $sInputType = self::ENUM_INPUT_TYPE_SINGLE_INPUT; $aEventsList[] = 'validate'; $aEventsList[] = 'keyup'; $aEventsList[] = 'change'; @@ -1835,6 +1874,7 @@ HTML break; case 'Duration': + $sInputType = self::ENUM_INPUT_TYPE_MULTIPLE_INPUTS; $aEventsList[] = 'validate'; $aEventsList[] = 'change'; $oPage->add_ready_script("$('#{$iId}_d').bind('keyup change', function(evt, sFormId) { return UpdateDuration('$iId'); });"); @@ -1854,6 +1894,7 @@ HTML break; case 'Password': + $sInputType = self::ENUM_INPUT_TYPE_PASSWORD; $aEventsList[] = 'validate'; $aEventsList[] = 'keyup'; $aEventsList[] = 'change'; @@ -1863,6 +1904,7 @@ HTML case 'OQLExpression': case 'Text': + $sInputType = self::ENUM_INPUT_TYPE_TEXTAREA; $aEventsList[] = 'validate'; $aEventsList[] = 'keyup'; $aEventsList[] = 'change'; @@ -1871,22 +1913,19 @@ HTML $aStyles = array(); $sStyle = ''; $sWidth = $oAttDef->GetWidth(); - if (!empty($sWidth)) - { + if (!empty($sWidth)) { $aStyles[] = 'width:'.$sWidth; } $sHeight = $oAttDef->GetHeight(); - if (!empty($sHeight)) - { + if (!empty($sHeight)) { $aStyles[] = 'height:'.$sHeight; } - if (count($aStyles) > 0) - { + if (count($aStyles) > 0) { $sStyle = 'style="'.implode('; ', $aStyles).'"'; } if ($oAttDef->GetEditClass() == 'OQLExpression') { - // predefined queries N°3227 + // N°3227 button to open predefined queries dialog $sPredefinedBtnId = 'predef_btn_'.$sFieldPrefix.$sAttCode.$sNameSuffix; $sSearchQueryLbl = Dict::S('UI:Edit:SearchQuery'); $oPredefQueryButton = ButtonUIBlockFactory::MakeIconLink( @@ -1951,12 +1990,12 @@ JS } else { $sAdditionalStuff = ''; } - // Ok, the text area is drawn here - $sHTMLValue = "$sAdditionalStuff
{$sValidationSpan}{$sReloadSpan}"; + // Ok, the text area is drawn here + $sHTMLValue = "$sAdditionalStuff
{$sValidationSpan}{$sReloadSpan}"; - $oPage->add_ready_script( - <<add_ready_script( + <<GetWidth(); - if (!empty($sWidth)) - { + if (!empty($sWidth)) { $aStyles[] = 'width:'.$sWidth; } $sHeight = $oAttDef->GetHeight(); - if (!empty($sHeight)) - { + if (!empty($sHeight)) { $aStyles[] = 'height:'.$sHeight; } - if (count($aStyles) > 0) - { + if (count($aStyles) > 0) { $sStyle = 'style="'.implode('; ', $aStyles).'"'; } @@ -2005,8 +2042,7 @@ EOF // Note: This should be refactored for all types of attribute (see at the end of this function) but as we are doing this for a maintenance release, we are scheduling it for the next main release in to order to avoid regressions as much as possible. $sNullValue = $oAttDef->GetNullValue(); - if (!is_numeric($sNullValue)) - { + if (!is_numeric($sNullValue)) { $sNullValue = "'$sNullValue'"; // Add quotes to turn this into a JS string if it's not a number } $sOriginalValue = ($iFlags & OPT_ATT_MUSTCHANGE) ? json_encode($value->GetModifiedEntry('html')) : 'undefined'; @@ -2045,9 +2081,10 @@ $('#$iId').bind('update', function(evt){ }); EOF ); - break; + break; case 'HTML': + $sInputType = self::ENUM_INPUT_TYPE_HTML_EDITOR; $sEditValue = $oAttDef->GetEditValue($value); $oWidget = new UIHTMLEditorWidget($iId, $oAttDef, $sNameSuffix, $sFieldPrefix, $sHelpText, $sValidationSpan.$sReloadSpan, $sEditValue, $bMandatory); @@ -2055,13 +2092,11 @@ EOF break; case 'LinkedSet': - if ($oAttDef->IsIndirect()) - { + $sInputType = ''; // TODO drop down VS autocomplete ? + if ($oAttDef->IsIndirect()) { $oWidget = new UILinksWidget($sClass, $sAttCode, $iId, $sNameSuffix, $oAttDef->DuplicatesAllowed()); - } - else - { + } else { $oWidget = new UILinksWidgetDirect($sClass, $sAttCode, $iId, $sNameSuffix); } $aEventsList[] = 'validate'; @@ -2071,12 +2106,12 @@ EOF break; case 'Document': + $sInputType = self::ENUM_INPUT_TYPE_DOCUMENT; $aEventsList[] = 'validate'; $aEventsList[] = 'change'; $oDocument = $value; // Value is an ormDocument object $sFileName = ''; - if (is_object($oDocument)) - { + if (is_object($oDocument)) { $sFileName = $oDocument->GetFileName(); } $iMaxFileSize = utils::ConvertToBytes(ini_get('upload_max_filesize')); @@ -2088,20 +2123,20 @@ EOF ENT_QUOTES, 'UTF-8')."\"/>\n"; $sHTMLValue .= "".htmlentities($sFileName, ENT_QUOTES, 'UTF-8')."  "; - $sHTMLValue .= "
"; + $sHTMLValue .= "
"; $sHTMLValue .= "
"; $sHTMLValue .= "
"; $sHTMLValue .= "
\n"; $sHTMLValue .= "\n"; $sHTMLValue .= "\n"; $sHTMLValue .= "{$sValidationSpan}{$sReloadSpan}\n"; - if ($sFileName == '') - { + if ($sFileName == '') { $oPage->add_ready_script("$('#remove_attr_{$iId}').hide();"); } break; case 'Image': + $sInputType = self::ENUM_INPUT_TYPE_IMAGE; $aEventsList[] = 'validate'; $aEventsList[] = 'change'; $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/edit_image.js'); @@ -2143,6 +2178,7 @@ EOF break; case 'One Way Password': + $sInputType = self::ENUM_INPUT_TYPE_PASSWORD; $aEventsList[] = 'validate'; $oWidget = new UIPasswordWidget($sAttCode, $iId, $sNameSuffix); $sHTMLValue = $oWidget->Display($oPage, $aArgs); @@ -2150,16 +2186,14 @@ EOF break; case 'ExtKey': + $sInputType = ''; // TODO /** @var \AttributeExternalKey $oAttDef */ $aEventsList[] = 'validate'; $aEventsList[] = 'change'; - if ($bPreserveCurrentValue) - { + if ($bPreserveCurrentValue) { $oAllowedValues = MetaModel::GetAllowedValuesAsObjectSet($sClass, $sAttCode, $aArgs, '', $value); - } - else - { + } else { $oAllowedValues = MetaModel::GetAllowedValuesAsObjectSet($sClass, $sAttCode, $aArgs); } $sFieldName = $sFieldPrefix.$sAttCode.$sNameSuffix; @@ -2167,15 +2201,14 @@ EOF $aExtKeyParams['iFieldSize'] = $oAttDef->GetMaxSize(); $aExtKeyParams['iMinChars'] = $oAttDef->GetMinAutoCompleteChars(); $sHTMLValue = UIExtKeyWidget::DisplayFromAttCode($oPage, $sAttCode, $sClass, $oAttDef->GetLabel(), - $oAllowedValues, $value, $iId, $bMandatory, $sFieldName, $sFormPrefix, $aExtKeyParams); + $oAllowedValues, $value, $iId, $bMandatory, $sFieldName, $sFormPrefix, $aExtKeyParams, false, $sInputType); $sHTMLValue .= "\n"; $bHasExtKeyUpdatingRemoteClassFields = ( array_key_exists('replaceDependenciesByRemoteClassFields', $aArgs) && ($aArgs['replaceDependenciesByRemoteClassFields']) ); - if ($bHasExtKeyUpdatingRemoteClassFields) - { + if ($bHasExtKeyUpdatingRemoteClassFields) { // On this field update we need to update all the corresponding remote class fields // Used when extkey widget is in a linkedset indirect $sWizardHelperJsVarName = $aArgs['wizHelperRemote']; @@ -2257,6 +2290,7 @@ JS case 'Set': case 'TagSet': + $sInputType = self::ENUM_INPUT_TYPE_TAGSET; $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'/js/selectize.min.js'); $oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/selectize.default.css'); $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'/js/jquery.itop-set-widget.js'); @@ -2297,6 +2331,7 @@ JS case 'radio': case 'radio_horizontal': case 'radio_vertical': + $sInputType = self::ENUM_INPUT_TYPE_RADIO; $aEventsList[] = 'change'; $sHTMLValue = "
"; $bVertical = ($sDisplayStyle != 'radio_horizontal'); @@ -2307,16 +2342,14 @@ JS case 'select': default: + $sInputType = self::ENUM_INPUT_TYPE_DROPDOWN_RAW; $aEventsList[] = 'change'; $sHTMLValue = "
iId\">"; - $sJsonOptions=json_encode($aOptions); + $sJsonOptions = json_encode($aOptions); $oPage->add_ready_script( <<iId} = new ExtKeyWidget('{$this->iId}', '{$this->sTargetClass}', '$sFilter', '$sTitle', true, $sWizHelper, '{$this->sAttCode}', $sJSSearchMode, $sJSDoSearch); @@ -272,14 +306,13 @@ EOF if (is_null($value) || ($value == 0)) // Null values are displayed as '' { $sDisplayValue = isset($aArgs['sDefaultValue']) ? $aArgs['sDefaultValue'] : ''; - } - else - { + } else { $sDisplayValue = $this->GetObjectName($value); } $iMinChars = isset($aArgs['iMinChars']) ? $aArgs['iMinChars'] : 2; //@@@ $this->oAttDef->GetMinAutoCompleteChars(); // the input for the auto-complete + $sInputType = CmdbAbstractObject::ENUM_INPUT_TYPE_AUTOCOMPLETE; $sHTMLValue .= "iId\" value=\"$sDisplayValue\"/>"; // another hidden input to store & pass the object's Id @@ -419,17 +452,40 @@ JS return $sHTMLValue; } + /** * @deprecated Use DisplayBob * Get the HTML fragment corresponding to the ext key editing widget - * @param WebPage $oP The web page used for all the output + * + * @param \WebPage $oPage + * @param int $iMaxComboLength + * @param boolean $bAllowTargetCreation + * @param string $sTitle + * @param \DBObjectset $oAllowedValues + * @param mixed $value + * @param int $iInputId + * @param boolean $bMandatory + * @param strin $sFieldName + * @param string $sFormPrefix * @param array $aArgs Extra context arguments + * @param null $bSearchMode + * @param string $sDisplayStyle + * @param boolean $bSearchMultiple + * @param string $sInputType type of field rendering, contains one of the \cmdbAbstractObject::ENUM_INPUT_TYPE_* constants + * * @return string The HTML fragment to be inserted into the page + * @throws \ConfigException + * @throws \CoreException + * @throws \CoreUnexpectedValue + * @throws \MissingQueryArgument + * @throws \MySQLException + * @throws \MySQLHasGoneAwayException + * + * @since 3.0.0 N°3750 new $sInputType parameter */ - public function Display(WebPage $oPage, $iMaxComboLength, $bAllowTargetCreation, $sTitle, DBObjectset $oAllowedValues, $value, $iInputId, $bMandatory, $sFieldName, $sFormPrefix = '', $aArgs = array(), $bSearchMode = null, $sDisplayStyle = 'select', $bSearchMultiple = true) + public function Display(WebPage $oPage, $iMaxComboLength, $bAllowTargetCreation, $sTitle, DBObjectset $oAllowedValues, $value, $iInputId, $bMandatory, $sFieldName, $sFormPrefix = '', $aArgs = array(), $bSearchMode = null, $sDisplayStyle = 'select', $bSearchMultiple = true, &$sInputType = '') { - if (!is_null($bSearchMode)) - { + if (!is_null($bSearchMode)) { $this->bSearchMode = $bSearchMode; } $sTitle = addslashes($sTitle); @@ -443,27 +499,20 @@ JS $sHTMLValue = "
"; $sFilter = addslashes($oAllowedValues->GetFilter()->ToOQL()); - if($this->bSearchMode) - { + if ($this->bSearchMode) { $sWizHelper = 'null'; $sWizHelperJSON = "''"; $sJSSearchMode = 'true'; - } - else - { - if (isset($aArgs['wizHelper'])) - { + } else { + if (isset($aArgs['wizHelper'])) { $sWizHelper = $aArgs['wizHelper']; - } - else - { + } else { $sWizHelper = 'oWizardHelper'.$sFormPrefix; } $sWizHelperJSON = $sWizHelper.'.UpdateWizardToJSON()'; $sJSSearchMode = 'false'; } - if (is_null($oAllowedValues)) - { + if (is_null($oAllowedValues)) { throw new Exception('Implementation: null value for allowed values definition'); } $oAllowedValues->SetShowObsoleteData(utils::ShowObsoleteData()); @@ -472,84 +521,71 @@ JS $sJSDoSearch = $bDoSearch ? 'true' : 'false'; // We just need to compare the number of entries with MaxComboLength, so no need to get the real count. - if (!$oAllowedValues->CountExceeds($iMaxComboLength)) - { - // Discrete list of values, use a SELECT or RADIO buttons depending on the config - switch($sDisplayStyle) - { + if (!$oAllowedValues->CountExceeds($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 = null; + $sInputType = CmdbAbstractObject::ENUM_INPUT_TYPE_RADIO; + $sValidationField = null; - $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}", false /* $bMandatory will be placed manually */, $bVertical, $sValidationField); - $aEventsList[] ='change'; - break; + $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}", false /* $bMandatory will be placed manually */, $bVertical, $sValidationField); + $aEventsList[] = 'change'; + break; case 'select': case 'list': default: + $sHelpText = ''; + $sHTMLValue .= "
\n"; - $sHelpText = ''; //$this->oAttDef->GetHelpOnEdition(); - $sHTMLValue .= "
\n"; - - if ($this->bSearchMode) - { - if ($bSearchMultiple) - { - $sHTMLValue .= "iId\">\n"; + } else { + $sHTMLValue .= "iId\">\n"; - $sDisplayValue = isset($aArgs['sDefaultValue']) ? $aArgs['sDefaultValue'] : Dict::S('UI:SearchValue:Any'); - $sHTMLValue .= "\n"; + $sHTMLValue .= "\n"; } - } - else - { - $sHTMLValue .= "\n"; $sHTMLValue .= "
\n"; - if (($this->bSearchMode) && $bSearchMultiple) - { + $sInputType = CmdbAbstractObject::ENUM_INPUT_TYPE_DROPDOWN_RAW; + if (($this->bSearchMode) && $bSearchMultiple) { + $sInputType = CmdbAbstractObject::ENUM_INPUT_TYPE_DROPDOWN_MULTIPLE_CHOICES; $aOptions = array( 'header' => true, 'checkAllText' => Dict::S('UI:SearchValue:CheckAll'), @@ -560,36 +596,32 @@ EOF ); $sJSOptions = json_encode($aOptions); $oPage->add_ready_script("$('.multiselect').multiselect($sJSOptions);"); - } - $oPage->add_ready_script( - <<add_ready_script( + <<iId} = new ExtKeyWidget('{$this->iId}', '{$this->sTargetClass}', '$sFilter', '$sTitle', true, $sWizHelper, '{$this->sAttCode}', $sJSSearchMode, $sJSDoSearch); oACWidget_{$this->iId}.emptyHtml = "

$sMessage

"; $('#$this->iId').bind('update', function() { oACWidget_{$this->iId}.Update(); } ); $('#$this->iId').bind('change', function() { $(this).trigger('extkeychange') } ); EOF - ); - } // Switch - } - else - { + ); + } + } else { // Too many choices, use an autocomplete + $sInputType = CmdbAbstractObject::ENUM_INPUT_TYPE_AUTOCOMPLETE; // Check that the given value is allowed $oSearch = $oAllowedValues->GetFilter(); $oSearch->AddCondition('id', $value); $oSet = new DBObjectSet($oSearch); - if ($oSet->Count() == 0) - { + if ($oSet->Count() == 0) { $value = null; } if (is_null($value) || ($value == 0)) // Null values are displayed as '' { $sDisplayValue = isset($aArgs['sDefaultValue']) ? $aArgs['sDefaultValue'] : ''; - } - else - { + } else { $sDisplayValue = $this->GetObjectName($value); } $iMinChars = isset($aArgs['iMinChars']) ? $aArgs['iMinChars'] : 2; //@@@ $this->oAttDef->GetMinAutoCompleteChars(); @@ -615,33 +647,31 @@ EOF EOF ); } - if ($bExtensions && MetaModel::IsHierarchicalClass($this->sTargetClass) !== false) - { + if ($bExtensions && MetaModel::IsHierarchicalClass($this->sTargetClass) !== false) { $sHTMLValue .= "
iId}\" onClick=\"oACWidget_{$this->iId}.HKDisplay();\">
"; $oPage->add_ready_script( -<<iId}').length == 0) { $('body').append('
'); } JS -); + ); } - if ($bCreate && $bExtensions) - { + if ($bCreate && $bExtensions) { $sCallbackName = (MetaModel::IsAbstract($this->sTargetClass)) ? 'SelectObjectClass' : 'CreateObject'; $sHTMLValue .= "
iId}\" onClick=\"oACWidget_{$this->iId}.{$sCallbackName}();\">
"; $oPage->add_ready_script( -<<iId}').length == 0) { $('body').append('
'); } JS -); + ); } - $sHTMLValue .= "
"; + $sHTMLValue .= "
"; $sHTMLValue .= "iId}\">iId}\">"; return $sHTMLValue; diff --git a/sources/application/UI/Base/Component/Field/Field.php b/sources/application/UI/Base/Component/Field/Field.php index e3c5ff3a6..44ba85e0b 100644 --- a/sources/application/UI/Base/Component/Field/Field.php +++ b/sources/application/UI/Base/Component/Field/Field.php @@ -345,4 +345,9 @@ class Field extends UIContentBlock { $this->AddDataAttribute('input-id', $sInputId); } + + public function SetInputType(string $sInputType) + { + $this->AddDataAttribute('input-type', $sInputType); + } } \ No newline at end of file diff --git a/sources/application/UI/Base/Component/Field/FieldUIBlockFactory.php b/sources/application/UI/Base/Component/Field/FieldUIBlockFactory.php index b8848e228..09871db1f 100644 --- a/sources/application/UI/Base/Component/Field/FieldUIBlockFactory.php +++ b/sources/application/UI/Base/Component/Field/FieldUIBlockFactory.php @@ -32,6 +32,7 @@ class FieldUIBlockFactory extends AbstractUIBlockFactory 'value_raw' => 'SetValueRaw', 'comments' => 'SetComments', 'input_id' => 'SetInputId', + 'input_type' => 'SetInputType', ]; foreach ($aParamsMapping as $sParamKey => $sFieldMethod) { self::UpdateFieldFromParams($oField, $sFieldMethod, $aParams, $sParamKey);