From ecf385b754e87a16668420488977e7eec261c90e Mon Sep 17 00:00:00 2001 From: Stephen Abello Date: Fri, 28 Aug 2026 15:31:53 +0200 Subject: [PATCH] Add data-* to property fields --- application/forms.class.inc.php | 40 ++++++++++++++++++++++++++++----- js/property_field.js | 1 + 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/application/forms.class.inc.php b/application/forms.class.inc.php index 61f62ded64..8ae199749a 100644 --- a/application/forms.class.inc.php +++ b/application/forms.class.inc.php @@ -220,10 +220,16 @@ class DesignerForm $sValidationFields = ''.$sValidation.'
' .$this->EndRow(); + $aPropertyFieldData = [ + 'code' => $oField->GetCode(), + 'type' => $oField->GetInputType(), + 'label' => $aRow['label'], + 'raw-value' => $oField->GetRawValue(), + ]; if (is_null($aRow['label'])) { - $sReturn .= $this->StartRow($sFieldId).''.$aRow['value']; + $sReturn .= $this->StartRow($sFieldId, $aPropertyFieldData).''.$aRow['value']; } else { - $sReturn .= $this->StartRow($sFieldId).''.$aRow['label'].''.$aRow['value']; + $sReturn .= $this->StartRow($sFieldId, $aPropertyFieldData).''.$aRow['label'].''.$aRow['value']; } if (!($oField instanceof DesignerFormSelectorField) && !($oField instanceof DesignerMultipleSubFormField)) { $sReturn .= $sValidationFields; @@ -294,12 +300,21 @@ EOF } } - public function StartRow($sFieldId = null) + public function StartRow($sFieldId = null, $aPropertyFieldData = []) { - if ($sFieldId != null) { - return ''; + $sPropertyFieldAttributes = ''; + foreach ($aPropertyFieldData as $sAttribute => $value) { + if (is_array($value)) { + $value = json_encode($value); + } elseif (is_null($value)) { + $value = ''; + } + $sPropertyFieldAttributes .= ' data-property-field-'.$sAttribute.'="'.utils::EscapeHtml((string)$value).'"'; } - return ''; + if ($sFieldId != null) { + return ''; + } + return ''; } public function EndRow() @@ -679,6 +694,14 @@ class DesignerFormField return $this->sCode; } + /** + * @return mixed + */ + public function GetRawValue() + { + return $this->defaultValue; + } + /** * @param \DesignerForm $oForm */ @@ -1629,6 +1652,11 @@ class DesignerFormSelectorField extends DesignerFormField return 'selector_property_field'; } + public function GetRawValue() + { + return $this->defaultRealValue; + } + public function AddSubForm($oSubForm, $sLabel, $sValue) { $this->aSubForms[] = ['form' => $oSubForm, 'label' => $sLabel, 'value' => $sValue]; diff --git a/js/property_field.js b/js/property_field.js index cd51fd5850..d895b9aea3 100644 --- a/js/property_field.js +++ b/js/property_field.js @@ -27,6 +27,7 @@ $(function() this.element .addClass( "itop-property-field ibo-field" ) + .attr('data-role', 'ibo-property-field') .on('apply_changes.itop-property-field', function(){me._do_apply();} ); this.bModified = false;