diff --git a/Build/Sources/TypeScript/backend/form-engine-suggest.ts b/Build/Sources/TypeScript/backend/form-engine-suggest.ts index 8f9d5e34828a0fdf0aa8d175eaec7e22059de005..754a8feea19fd4d60adcec0e24b7db608ace0130 100644 --- a/Build/Sources/TypeScript/backend/form-engine-suggest.ts +++ b/Build/Sources/TypeScript/backend/form-engine-suggest.ts @@ -81,18 +81,20 @@ class FormEngineSuggest { return; } + const uid = parseInt(target.dataset.uid, 10); this.currentRequest = new AjaxRequest(TYPO3.settings.ajaxUrls.record_suggest); this.currentRequest.post({ value: target.value, tableName: target.dataset.tablename, fieldName: target.dataset.fieldname, - uid: parseInt(target.dataset.uid, 10), + uid: (isNaN(uid) ? null : uid), pid: parseInt(target.dataset.pid, 10), dataStructureIdentifier: target.dataset.datastructureidentifier, flexFormSheetName: target.dataset.flexformsheetname, flexFormFieldName: target.dataset.flexformfieldname, flexFormContainerName: target.dataset.flexformcontainername, flexFormContainerFieldName: target.dataset.flexformcontainerfieldname, + recordTypeValue: target.dataset.recordtypevalue, }).then(async (response: AjaxResponse): Promise<void> => { const resultSet = await response.raw().text(); this.resultContainer.setAttribute('results', resultSet); diff --git a/typo3/sysext/backend/Classes/Controller/Wizard/SuggestWizardController.php b/typo3/sysext/backend/Classes/Controller/Wizard/SuggestWizardController.php index 8443402af54e808a607bcf4e19277be7c4997caf..d464b37c8d40056fac10f6b38d7298440c9fec3b 100644 --- a/typo3/sysext/backend/Classes/Controller/Wizard/SuggestWizardController.php +++ b/typo3/sysext/backend/Classes/Controller/Wizard/SuggestWizardController.php @@ -54,6 +54,7 @@ class SuggestWizardController $flexFormFieldName = $parsedBody['flexFormFieldName'] ?? null; $flexFormContainerName = $parsedBody['flexFormContainerName'] ?? null; $flexFormContainerFieldName = $parsedBody['flexFormContainerFieldName'] ?? null; + $recordType = (string)($parsedBody['recordTypeValue'] ?? ''); // Determine TCA config of field if (empty($dataStructureIdentifier)) { @@ -62,8 +63,13 @@ class SuggestWizardController $fieldNameInPageTsConfig = $fieldName; // With possible columnsOverrides - $row = BackendUtility::getRecord($tableName, $uid) ?? []; - $recordType = BackendUtility::getTCAtypeValue($tableName, $row); + // @todo Validate if we can move this fallback recordType determination, should be do-able in v13?! + if ($recordType === '') { + $recordType = BackendUtility::getTCAtypeValue( + $tableName, + BackendUtility::getRecord($tableName, $uid) ?? [] + ); + } $columnsOverridesConfigOfField = $GLOBALS['TCA'][$tableName]['types'][$recordType]['columnsOverrides'][$fieldName]['config'] ?? null; if ($columnsOverridesConfigOfField) { ArrayUtility::mergeRecursiveWithOverrule($fieldConfig, $columnsOverridesConfigOfField); diff --git a/typo3/sysext/backend/Classes/Form/Element/GroupElement.php b/typo3/sysext/backend/Classes/Form/Element/GroupElement.php index d9751e978c8d8f70a7f431af3a1e11d26937bdfa..87bd519b798ce42d7a0e3ee05c79d6e4d0978296 100644 --- a/typo3/sysext/backend/Classes/Form/Element/GroupElement.php +++ b/typo3/sysext/backend/Classes/Form/Element/GroupElement.php @@ -116,6 +116,7 @@ class GroupElement extends AbstractFormElement $parameterArray = $this->data['parameterArray']; $config = $parameterArray['fieldConf']['config']; $elementName = $parameterArray['itemFormElName']; + $recordTypeValue = $this->data['recordTypeValue'] ?? null; $selectedItems = $parameterArray['itemFormElValue']; $maxItems = $config['maxitems']; @@ -269,6 +270,9 @@ class GroupElement extends AbstractFormElement $html[] = ' data-flexformfieldname="' . htmlspecialchars($flexFormFieldName) . '"'; $html[] = ' data-flexformcontainername="' . htmlspecialchars($flexFormContainerName) . '"'; $html[] = ' data-flexformcontainerfieldname="' . htmlspecialchars($flexFormContainerFieldName) . '"'; + if ($recordTypeValue !== null && $recordTypeValue !== '') { + $html[] = ' data-recordtypevalue="' . htmlspecialchars($recordTypeValue) . '"'; + } $html[] = '/>'; $html[] = '</div>'; $html[] = '</div>'; diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/form-engine-suggest.js b/typo3/sysext/backend/Resources/Public/JavaScript/form-engine-suggest.js index 2d4532c702e5dd8a00633e30fa8474022c03c728..7ae93231dc9df3afc28cdbd86117557d360ad4e0 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/form-engine-suggest.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/form-engine-suggest.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -import"@typo3/backend/form-engine/element/suggest/result-container.js";import DocumentService from"@typo3/core/document-service.js";import FormEngine from"@typo3/backend/form-engine.js";import RegularEvent from"@typo3/core/event/regular-event.js";import DebounceEvent from"@typo3/core/event/debounce-event.js";import AjaxRequest from"@typo3/core/ajax/ajax-request.js";class FormEngineSuggest{constructor(e){this.currentRequest=null,this.handleKeyDown=e=>{if("ArrowDown"!==e.key)"Escape"===e.key&&(e.preventDefault(),this.resultContainer.hidden=!0);else{e.preventDefault();const t=JSON.parse(this.resultContainer.getAttribute("results"));t?.length>0&&(this.resultContainer.hidden=!1);const n=this.resultContainer.querySelector("typo3-backend-formengine-suggest-result-item");n?.focus()}},this.element=e,DocumentService.ready().then((()=>{this.initialize(e),this.registerEvents()}))}initialize(e){const t=e.closest(".t3-form-suggest-container");this.resultContainer=document.createElement("typo3-backend-formengine-suggest-result-container"),this.resultContainer.hidden=!0,t.append(this.resultContainer)}registerEvents(){new RegularEvent("typo3:formengine:suggest-item-chosen",(e=>{let t="";t="select"===this.element.dataset.fieldtype?e.detail.element.uid:e.detail.element.table+"_"+e.detail.element.uid,FormEngine.setSelectOptionFromExternalSource(this.element.dataset.field,t,e.detail.element.label,e.detail.element.label),FormEngine.Validation.markFieldAsChanged(document.querySelector('input[name="'+this.element.dataset.field+'"]')),this.resultContainer.hidden=!0})).bindTo(this.resultContainer),new RegularEvent("focus",(()=>{const e=JSON.parse(this.resultContainer.getAttribute("results"));e?.length>0&&(this.resultContainer.hidden=!1)})).bindTo(this.element),new RegularEvent("blur",(e=>{"typo3-backend-formengine-suggest-result-item"!==e.relatedTarget?.tagName.toLowerCase()&&(this.resultContainer.hidden=!0)})).bindTo(this.element),new DebounceEvent("input",(e=>{this.currentRequest instanceof AjaxRequest&&this.currentRequest.abort();const t=e.target;t.value.length<parseInt(t.dataset.minchars,10)||(this.currentRequest=new AjaxRequest(TYPO3.settings.ajaxUrls.record_suggest),this.currentRequest.post({value:t.value,tableName:t.dataset.tablename,fieldName:t.dataset.fieldname,uid:parseInt(t.dataset.uid,10),pid:parseInt(t.dataset.pid,10),dataStructureIdentifier:t.dataset.datastructureidentifier,flexFormSheetName:t.dataset.flexformsheetname,flexFormFieldName:t.dataset.flexformfieldname,flexFormContainerName:t.dataset.flexformcontainername,flexFormContainerFieldName:t.dataset.flexformcontainerfieldname}).then((async e=>{const t=await e.raw().text();this.resultContainer.setAttribute("results",t),this.resultContainer.hidden=!1})))})).bindTo(this.element),new RegularEvent("keydown",this.handleKeyDown).bindTo(this.element)}}export default FormEngineSuggest; \ No newline at end of file +import"@typo3/backend/form-engine/element/suggest/result-container.js";import DocumentService from"@typo3/core/document-service.js";import FormEngine from"@typo3/backend/form-engine.js";import RegularEvent from"@typo3/core/event/regular-event.js";import DebounceEvent from"@typo3/core/event/debounce-event.js";import AjaxRequest from"@typo3/core/ajax/ajax-request.js";class FormEngineSuggest{constructor(e){this.currentRequest=null,this.handleKeyDown=e=>{if("ArrowDown"!==e.key)"Escape"===e.key&&(e.preventDefault(),this.resultContainer.hidden=!0);else{e.preventDefault();const t=JSON.parse(this.resultContainer.getAttribute("results"));t?.length>0&&(this.resultContainer.hidden=!1);const n=this.resultContainer.querySelector("typo3-backend-formengine-suggest-result-item");n?.focus()}},this.element=e,DocumentService.ready().then((()=>{this.initialize(e),this.registerEvents()}))}initialize(e){const t=e.closest(".t3-form-suggest-container");this.resultContainer=document.createElement("typo3-backend-formengine-suggest-result-container"),this.resultContainer.hidden=!0,t.append(this.resultContainer)}registerEvents(){new RegularEvent("typo3:formengine:suggest-item-chosen",(e=>{let t="";t="select"===this.element.dataset.fieldtype?e.detail.element.uid:e.detail.element.table+"_"+e.detail.element.uid,FormEngine.setSelectOptionFromExternalSource(this.element.dataset.field,t,e.detail.element.label,e.detail.element.label),FormEngine.Validation.markFieldAsChanged(document.querySelector('input[name="'+this.element.dataset.field+'"]')),this.resultContainer.hidden=!0})).bindTo(this.resultContainer),new RegularEvent("focus",(()=>{const e=JSON.parse(this.resultContainer.getAttribute("results"));e?.length>0&&(this.resultContainer.hidden=!1)})).bindTo(this.element),new RegularEvent("blur",(e=>{"typo3-backend-formengine-suggest-result-item"!==e.relatedTarget?.tagName.toLowerCase()&&(this.resultContainer.hidden=!0)})).bindTo(this.element),new DebounceEvent("input",(e=>{this.currentRequest instanceof AjaxRequest&&this.currentRequest.abort();const t=e.target;if(t.value.length<parseInt(t.dataset.minchars,10))return;const n=parseInt(t.dataset.uid,10);this.currentRequest=new AjaxRequest(TYPO3.settings.ajaxUrls.record_suggest),this.currentRequest.post({value:t.value,tableName:t.dataset.tablename,fieldName:t.dataset.fieldname,uid:isNaN(n)?null:n,pid:parseInt(t.dataset.pid,10),dataStructureIdentifier:t.dataset.datastructureidentifier,flexFormSheetName:t.dataset.flexformsheetname,flexFormFieldName:t.dataset.flexformfieldname,flexFormContainerName:t.dataset.flexformcontainername,flexFormContainerFieldName:t.dataset.flexformcontainerfieldname,recordTypeValue:t.dataset.recordtypevalue}).then((async e=>{const t=await e.raw().text();this.resultContainer.setAttribute("results",t),this.resultContainer.hidden=!1}))})).bindTo(this.element),new RegularEvent("keydown",this.handleKeyDown).bindTo(this.element)}}export default FormEngineSuggest; \ No newline at end of file