Merge remote-tracking branch 'origin/support/3.1' into support/3.2

This commit is contained in:
jf-cbd
2025-02-21 13:23:57 +01:00

View File

@@ -1399,55 +1399,56 @@ class ObjectFormManager extends FormManager
$this->aFieldsAtts = array(); $this->aFieldsAtts = array();
$this->aExtraData = array(); $this->aExtraData = array();
$aFieldsDMOnlyAttCodes = array(); $aFieldsDMOnlyAttCodes = array();
switch ($this->aFormProperties['type']) { if (array_key_exists('type', $this->aFormProperties)) {
case 'custom_list': switch ($this->aFormProperties['type']) {
case 'static': case 'custom_list':
foreach ($this->aFormProperties['fields'] as $sAttCode => $aOptions) { case 'static':
// When in a transition and no flags are specified for the field, we will retrieve its flags from DM later foreach ($this->aFormProperties['fields'] as $sAttCode => $aOptions) {
if ($this->IsTransitionForm() && empty($aOptions)) { // When in a transition and no flags are specified for the field, we will retrieve its flags from DM later
$aFieldsDMOnlyAttCodes[] = $sAttCode; if ($this->IsTransitionForm() && empty($aOptions)) {
continue; $aFieldsDMOnlyAttCodes[] = $sAttCode;
} continue;
}
// Otherwise we proceed as usual // Otherwise we proceed as usual
$iFieldFlags = OPT_ATT_NORMAL; $iFieldFlags = OPT_ATT_NORMAL;
// Checking if field should be slave // Checking if field should be slave
if (isset($aOptions['slave']) && ($aOptions['slave'] === true)) { if (isset($aOptions['slave']) && ($aOptions['slave'] === true)) {
$iFieldFlags = $iFieldFlags | OPT_ATT_SLAVE; $iFieldFlags = $iFieldFlags | OPT_ATT_SLAVE;
}
// Checking if field should be must_change
if (isset($aOptions['must_change']) && ($aOptions['must_change'] === true)) {
$iFieldFlags = $iFieldFlags | OPT_ATT_MUSTCHANGE;
}
// Checking if field should be must prompt
if (isset($aOptions['must_prompt']) && ($aOptions['must_prompt'] === true)) {
$iFieldFlags = $iFieldFlags | OPT_ATT_MUSTPROMPT;
}
// Checking if field should be hidden
if (isset($aOptions['hidden']) && ($aOptions['hidden'] === true)) {
$iFieldFlags = $iFieldFlags | OPT_ATT_HIDDEN;
}
// Checking if field should be readonly
if (isset($aOptions['read_only']) && ($aOptions['read_only'] === true)) {
$iFieldFlags = $iFieldFlags | OPT_ATT_READONLY;
}
// Checking if field should be mandatory
if (isset($aOptions['mandatory']) && ($aOptions['mandatory'] === true)) {
$iFieldFlags = $iFieldFlags | OPT_ATT_MANDATORY;
}
// Finally, adding the attribute and its flags
$this->aFieldsAtts[$sAttCode] = $iFieldFlags;
} }
// Checking if field should be must_change break;
if (isset($aOptions['must_change']) && ($aOptions['must_change'] === true)) {
$iFieldFlags = $iFieldFlags | OPT_ATT_MUSTCHANGE;
}
// Checking if field should be must prompt
if (isset($aOptions['must_prompt']) && ($aOptions['must_prompt'] === true)) {
$iFieldFlags = $iFieldFlags | OPT_ATT_MUSTPROMPT;
}
// Checking if field should be hidden
if (isset($aOptions['hidden']) && ($aOptions['hidden'] === true)) {
$iFieldFlags = $iFieldFlags | OPT_ATT_HIDDEN;
}
// Checking if field should be readonly
if (isset($aOptions['read_only']) && ($aOptions['read_only'] === true)) {
$iFieldFlags = $iFieldFlags | OPT_ATT_READONLY;
}
// Checking if field should be mandatory
if (isset($aOptions['mandatory']) && ($aOptions['mandatory'] === true)) {
$iFieldFlags = $iFieldFlags | OPT_ATT_MANDATORY;
}
// Finally, adding the attribute and its flags
$this->aFieldsAtts[$sAttCode] = $iFieldFlags;
}
break;
case 'zlist': case 'zlist':
foreach (MetaModel::FlattenZList(MetaModel::GetZListItems($sObjectClass, $this->aFormProperties['fields'])) as $sAttCode) { foreach (MetaModel::FlattenZList(MetaModel::GetZListItems($sObjectClass, $this->aFormProperties['fields'])) as $sAttCode) {
$this->aFieldsAtts[$sAttCode] = OPT_ATT_NORMAL; $this->aFieldsAtts[$sAttCode] = OPT_ATT_NORMAL;
} }
break; break;
}
} }
if (isset($this->aFormProperties['layout'])) {
if ($this->aFormProperties['layout'] !== null) {
$oXPath = new DOMXPath($this->oHtmlDocument); $oXPath = new DOMXPath($this->oHtmlDocument);
/** @var \DOMElement $oFieldNode */ /** @var \DOMElement $oFieldNode */
foreach ($oXPath->query('//div[contains(@class, "form_field")][@data-field-id]') as $oFieldNode) { foreach ($oXPath->query('//div[contains(@class, "form_field")][@data-field-id]') as $oFieldNode) {
@@ -1510,7 +1511,7 @@ class ObjectFormManager extends FormManager
// Also, retrieving mandatory attributes from metamodel to be able to complete the form with them if necessary // Also, retrieving mandatory attributes from metamodel to be able to complete the form with them if necessary
// //
// Note: When in a transition, we don't do this for fields that should be set from DM // Note: When in a transition, we don't do this for fields that should be set from DM
if ($this->aFormProperties['type'] !== 'static') { if (array_key_exists('type', $this->aFormProperties) && $this->aFormProperties['type'] !== 'static') {
if ($this->IsTransitionForm()) { if ($this->IsTransitionForm()) {
$aDatamodelAttCodes = $this->oObject->GetTransitionAttributes($this->aFormProperties['stimulus_code']); $aDatamodelAttCodes = $this->oObject->GetTransitionAttributes($this->aFormProperties['stimulus_code']);
} }
@@ -1616,7 +1617,7 @@ class ObjectFormManager extends FormManager
} }
$this->oHtmlDocument = new DOMDocument(); $this->oHtmlDocument = new DOMDocument();
if ($this->aFormProperties['layout'] !== null) { if (isset($this->aFormProperties['layout'])) {
// Checking if we need to render the template from twig to html in order to parse the fields // Checking if we need to render the template from twig to html in order to parse the fields
if ($this->aFormProperties['layout']['type'] === 'twig') { if ($this->aFormProperties['layout']['type'] === 'twig') {
if ($this->oFormHandlerHelper !== null) { if ($this->oFormHandlerHelper !== null) {