Last active
July 24, 2019 17:13
Revisions
-
derhansen revised this gist
Jul 24, 2019 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -45,6 +45,13 @@ class InlineReadOnly implements FormDataProviderInterface 'delete' => false, 'localize' => false, ]; foreach ([ 'inlineNewButtonStyle', 'inlineNewRelationButtonStyle', 'inlineOnlineMediaAddButtonStyle' ] as $field) { $result['processedTca']['columns'][$columnName]['config']['inline'][$field] = 'display: none;'; } } } -
derhansen created this gist
Feb 15, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,60 @@ <?php namespace Vendor\Extension\Backend\Form\FormDataProvider; use TYPO3\CMS\Backend\Form\FormDataProviderInterface; /** * Disables all IRRE Controls and sets fields of IRRE records to readonly * * Note: Depending on the TYPO3 backend user permissions, a user may still be able to edit record content * (e.g. if table is available in record list and user has sufficient rights to edit data). But for inline integration, * the record(s) should be readOnly. */ class InlineReadOnly implements FormDataProviderInterface { /** * @param array $result * @return array */ public function addData(array $result) { $result = $this->evaluateInlineReadOnlyState($result); return $result; } /** * Evaluates 'readOnly' TCA state. Removes controls for IRRE elements with readOnly state and * sets fields of child TCA to readOnly * * @param array $result * @return array */ protected function evaluateInlineReadOnlyState(array $result): array { // Disable all controls for the IRRE records foreach ($result['processedTca']['columns'] as $columnName => $columnConfiguration) { if (!isset($columnConfiguration['config']['readOnly'])) { continue; } elseif ((bool)$columnConfiguration['config']['readOnly'] === true) { $result['processedTca']['columns'][$columnName]['config']['appearance']['enabledControls'] = [ 'info' => false, 'new' => false, 'dragdrop' => false, 'sort' => false, 'hide' => false, 'delete' => false, 'localize' => false, ]; } } // Sets all fields to readOnly if parent inline element is readOnly if (isset($result['inlineParentConfig']) && $result['inlineParentConfig']['readOnly']) { foreach ($result['processedTca']['columns'] as $columnName => $columnConfiguration) { $result['processedTca']['columns'][$columnName]['config']['readOnly'] = true; } } return $result; } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ <?php defined('TYPO3_MODE') or die(); call_user_func(function () { $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'][ \Vendor\Extension\Backend\Form\FormDataProvider\InlineReadOnly::class ] = [ 'depends' => [ \TYPO3\CMS\Backend\Form\FormDataProvider\EvaluateDisplayConditions::class, ] ]; });