diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index c1742b9a4..83c1158e4 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -94,6 +94,8 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay /** @var string */ public const ENUM_INPUT_TYPE_RADIO = 'radio'; /** @var string */ + public const ENUM_INPUT_TYPE_CHECKBOX = 'checkbox'; + /** @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 diff --git a/application/forms.class.inc.php b/application/forms.class.inc.php index 2ef811a3b..1b1bf161f 100644 --- a/application/forms.class.inc.php +++ b/application/forms.class.inc.php @@ -102,12 +102,20 @@ class DesignerForm $sReturn .= '
'; $sReturn .= ''.$sLabel.''; } + /** @var \DesignerFormField $oField */ foreach($aFields as $oField) { $aRow = $oField->Render($oP, $sFormId); if ($oField->IsVisible()) { $sValidation = ''.$this->GetValidationArea($oField->GetFieldId()).''; $sField = $aRow['value'].$sValidation; - $aDetails[] = array('label' => $aRow['label'], 'value' => $sField); + $aDetails[] = array( + 'label' => $aRow['label'], + 'value' => $sField, + 'attcode' => $oField->GetCode(), + 'attlabel' => $aRow['label'], + 'inputid' => $this->GetFieldId($oField->GetCode()), + 'inputtype' => $oField->GetInputType(), + ); } else { $sHiddenFields .= $aRow['value']; } @@ -707,6 +715,19 @@ class DesignerFormField $this->aWidgetExtraParams = array(); } + /** + * Important, for now we use constants from the \cmdbAbstractObject class, introducing a coupling that should not exist. + * This has been traced under N°4241 and will be discussed during the next modernization batch. + * + * @return string|null Return the input type of the field + * @see \cmdbAbstractObject::ENUM_INPUT_TYPE_XXX + * @since 3.0.0 + */ + public function GetInputType(): ?string + { + return cmdbAbstractObject::ENUM_INPUT_TYPE_SINGLE_INPUT; + } + /** * @return string */ @@ -1047,6 +1068,14 @@ class DesignerLongTextField extends DesignerTextField $this->aCSSClasses[] = 'ibo-input-text'; } + /** + * @inheritDoc + */ + public function GetInputType(): string + { + return cmdbAbstractObject::ENUM_INPUT_TYPE_TEXTAREA; + } + public function Render(WebPage $oP, $sFormId, $sRenderMode='dialog') { $sId = $this->oForm->GetFieldId($this->sCode); @@ -1175,6 +1204,19 @@ class DesignerComboField extends DesignerFormField $this->bAutoApply = true; $this->bSorted = true; // Sorted by default } + + /** + * @inheritDoc + */ + public function GetInputType(): ?string + { + if ($this->bMultipleSelection) { + return cmdbAbstractObject::ENUM_INPUT_TYPE_DROPDOWN_MULTIPLE_CHOICES; + } + else { + return cmdbAbstractObject::ENUM_INPUT_TYPE_DROPDOWN_RAW; + } + } public function SetAllowedValues($aAllowedValues) { @@ -1311,6 +1353,14 @@ class DesignerBooleanField extends DesignerFormField $this->bAutoApply = true; $this->aCSSClasses[] = 'ibo-input-checkbox'; } + + /** + * @inheritDoc + */ + public function GetInputType(): ?string + { + return cmdbAbstractObject::ENUM_INPUT_TYPE_CHECKBOX; + } public function Render(WebPage $oP, $sFormId, $sRenderMode='dialog') { @@ -1370,6 +1420,14 @@ class DesignerHiddenField extends DesignerFormField { parent::__construct($sCode, $sLabel, $defaultValue); } + + /** + * @inheritDoc + */ + public function GetInputType(): ?string + { + return null; + } public function IsVisible() { @@ -1397,6 +1455,14 @@ class DesignerIconSelectionField extends DesignerFormField $this->bAutoApply = true; $this->sUploadUrl = null; } + + /** + * @inheritDoc + */ + public function GetInputType(): ?string + { + return cmdbAbstractObject::ENUM_INPUT_TYPE_DROPDOWN_DECORATED; + } public function SetAllowedValues($aAllowedValues) { @@ -1566,6 +1632,14 @@ class DesignerSortableField extends DesignerFormField parent::__construct($sCode, $sLabel, $defaultValue); $this->aAllowedValues = array(); } + + /** + * @inheritDoc + */ + public function GetInputType(): ?string + { + return null; + } public function SetAllowedValues($aAllowedValues) { @@ -1605,6 +1679,14 @@ class DesignerFormSelectorField extends DesignerFormField $this->aCSSClasses[] = 'ibo-input-select'; } + /** + * @inheritDoc + */ + public function GetInputType(): ?string + { + return null; + } + public function IsSorted() { return $this->bSorted; @@ -1790,6 +1872,14 @@ class DesignerSubFormField extends DesignerFormField parent::__construct('', $sLabel, ''); $this->oSubForm = $oSubForm; } + + /** + * @inheritDoc + */ + public function GetInputType(): ?string + { + return null; + } public function Render(WebPage $oP, $sFormId, $sRenderMode='dialog') { @@ -1834,6 +1924,14 @@ class DesignerStaticTextField extends DesignerFormField parent::__construct($sCode, $sLabel, $defaultValue); } + /** + * @inheritDoc + */ + public function GetInputType(): ?string + { + return null; + } + public function Render(WebPage $oP, $sFormId, $sRenderMode='dialog') { return array('label' => $this->sLabel, 'value' => $this->defaultValue); diff --git a/sources/application/WebPage/WebPage.php b/sources/application/WebPage/WebPage.php index 08fa88924..070e19810 100644 --- a/sources/application/WebPage/WebPage.php +++ b/sources/application/WebPage/WebPage.php @@ -977,6 +977,8 @@ JS; $sDataAttributeCode = isset($aAttrib['attcode']) ? 'data-attribute-code="'.$aAttrib['attcode'].'"' : ''; $sDataAttributeType = isset($aAttrib['atttype']) ? 'data-attribute-type="'.$aAttrib['atttype'].'"' : ''; $sDataAttributeLabel = isset($aAttrib['attlabel']) ? 'data-attribute-label="'.utils::HtmlEntities($aAttrib['attlabel']).'"' : ''; + $sDataInputId = isset($aAttrib['inputid']) ? 'data-input-id="'.utils::HtmlEntities($aAttrib['inputid']).'"' : ''; + $sDataInputType = isset($aAttrib['inputtype']) ? 'data-input-type="'.utils::HtmlEntities($aAttrib['inputtype']).'"' : ''; // - Attribute flags $sDataAttributeFlags = ''; if(isset($aAttrib['attflags'])) @@ -996,7 +998,7 @@ JS; // - Value raw $sDataValueRaw = isset($aAttrib['value_raw']) ? 'data-value-raw="'.utils::HtmlEntities($aAttrib['value_raw']).'"' : ''; - $sHtml .= "
\n"; + $sHtml .= "
\n"; $sHtml .= "
{$aAttrib['label']}
\n"; $sHtml .= "
\n";