-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add condition for saving hidden fields or not #33
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
use TYPO3\CMS\Core\Database\ConnectionPool; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Form\Domain\Finishers\AbstractFinisher; | ||
use TYPO3\CMS\Form\Domain\Model\FormElements\FormElementInterface; | ||
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; | ||
|
||
/** | ||
|
@@ -23,6 +24,7 @@ class LoggerFinisher extends AbstractFinisher | |
*/ | ||
protected $defaultOptions = [ | ||
'finisherVariables' => [], | ||
'saveHiddenElements' => true, | ||
]; | ||
|
||
/** | ||
|
@@ -45,7 +47,7 @@ public function __construct(string $finisherIdentifier = '', TypoScriptFrontendC | |
*/ | ||
protected function executeInternal() | ||
{ | ||
$formValues = $this->finisherContext->getFormValues(); | ||
$formValues = $this->getFormValues(); | ||
$formDefinition = $this->finisherContext->getFormRuntime()->getFormDefinition(); | ||
$data = [ | ||
'pid' => $this->frontendController->id, | ||
|
@@ -86,6 +88,47 @@ protected function getFinisherVariables(): array | |
return $finisherVariables; | ||
} | ||
|
||
/** | ||
* Returns all form values | ||
* Hidden fields will be rejected, if selected in finisher. | ||
* | ||
* @return array | ||
*/ | ||
protected function getFormValues(): array | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A method with this name has been added in the meantime, can you integrate your changes there? |
||
{ | ||
$formValues = $this->finisherContext->getFormValues(); | ||
|
||
if ($this->parseOption('saveHiddenElements')) { | ||
return $formValues; | ||
} | ||
|
||
$formDefinition = $this->finisherContext->getFormRuntime()->getFormDefinition(); | ||
|
||
foreach ($formValues as $formIdentifier => $value) { | ||
$element = $formDefinition->getElementByIdentifier($formIdentifier); | ||
$renderingOptions = $element->getRenderingOptions(); | ||
|
||
if (!$element instanceof FormElementInterface | ||
|| ( | ||
isset($renderingOptions['_isCompositeFormElement']) | ||
&& $renderingOptions['_isCompositeFormElement'] === true | ||
) | ||
|| ( | ||
isset($renderingOptions['_isHiddenFormElement']) | ||
&& $renderingOptions['_isHiddenFormElement'] === true | ||
) | ||
|| ( | ||
isset($renderingOptions['_isReadOnlyFormElement']) | ||
&& $renderingOptions['_isReadOnlyFormElement'] === true | ||
) | ||
Comment on lines
+117
to
+123
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two are gone with TYPO3v10 which is the minimum TYPO3 version by now. |
||
) { | ||
unset($formValues[$formIdentifier]); | ||
} | ||
} | ||
|
||
return $formValues; | ||
} | ||
|
||
/** | ||
* Gets the current language UID | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.