content_defender icon indicating copy to clipboard operation
content_defender copied to clipboard

Hiding CType from showitem breaks editing and creating content

Open jonakieling opened this issue 3 years ago • 0 comments

Hi there,

we want to hide the CType from editors by removing the field from the showitem and rely on default values. Notably, this way the CType is not send via the POST request of the form.

This leads to an exception thrown by DatabaseRecordTypeValue because the CType field is missing from the databaseRow at this point.

Looking into it, there are a couple of things that need to be adressed to fix this. So far, all in the DataHandler hooks.

1) This set of form data providers does not resolve the default values. https://github.com/IchHabRecht/content_defender/blob/1843e0d0825b78413ef20e4f1b82bdbfed8c52b9/Classes/Hooks/AbstractDataHandlerHook.php#L60-L68

2) Adding DatabaseRowInitializeNew before DatabaseRecordTypeValue does not work since the form data compiler is called with the command edit. This also requires to pass the defaults from the DataHandler into isRecordAllowedByRestriction. https://github.com/IchHabRecht/content_defender/blob/1843e0d0825b78413ef20e4f1b82bdbfed8c52b9/Classes/Hooks/AbstractDataHandlerHook.php#L72

3) Additionally after that the original record/incomingFieldArray is used, which does not have the CType field set. This always allows the element regardless of any configuration. https://github.com/IchHabRecht/content_defender/blob/1843e0d0825b78413ef20e4f1b82bdbfed8c52b9/Classes/Hooks/AbstractDataHandlerHook.php#L106-L111

Kind regards, Jona

jonakieling avatar Jun 28 '22 15:06 jonakieling