Task #82615
closedEXT:form - Add more explanations about the initializeFormElement hook into the docs.
100%
Description
When you use the BE module and you save a form default Value is set to ''
Then if you have some hook pre populating some field is having no effect as defaultValue: '' from Yaml file is having more priority.
I would like to think the way to fix it is not set defaultValue if it is empty, however I don't know which other implications could have.
hook function I'm using is
public function initializeFormElement(\TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface $renderable)
Updated by Ralf Zimmermann about 7 years ago
- Category set to Form Framework
- Status changed from New to Needs Feedback
- Assignee set to Juan Manuel Vergés Solanas
Can you provide your code from the Hook and the formDefinition yaml (please anonymize it)?
Actually this should work.
Updated by Juan Manuel Vergés Solanas about 7 years ago
public function initializeFormElement(\TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface $renderable)
{
if ($renderable->getUniqueIdentifier() === 'something-else') {
$renderable->setDefaultValue('foo');
}
}
renderingOptions:
submitButtonLabel: Submit
addQueryString: 'true'
type: Form
identifier: something
label: Something
prototypeName: standard
renderables:
-
renderingOptions:
previousButtonLabel: 'previous Step'
nextButtonLabel: 'next Step'
type: Page
identifier: page-1
label: ''
renderables:
-
defaultValue: ''
type: Hidden
identifier: else
label: 'Else'
Updated by Juan Manuel Vergés Solanas about 7 years ago
- Assignee changed from Juan Manuel Vergés Solanas to Ralf Zimmermann
Updated by Gerrit Code Review about 7 years ago
- Status changed from Needs Feedback to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54232
Updated by Gerrit Code Review about 7 years ago
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54234
Updated by Ralf Zimmermann about 7 years ago
- Tracker changed from Bug to Task
- Subject changed from ext:form defaultValue: '' and hook initializeFormElement for pre populating to EXT:form - Add more explanations about the initializeFormElement hook into the docs.
- Status changed from Under Review to Needs Feedback
This hook will be called after all properties from the prototype configuration are set in the form element but before the properties from
the form definition are set in the form element.
If you want to prefill form element data after the complete form element is configured you should use the afterBuildingFinished hook.
https://docs.typo3.org/typo3cms/extensions/form/latest/ApiReference/Index.html#afterbuildingfinished
Updated by Ralf Zimmermann about 7 years ago
- Status changed from Needs Feedback to Under Review
Updated by Gerrit Code Review about 7 years ago
Patch set 1 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54235
Updated by Ralf Zimmermann about 7 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 2a65199aae9d8f5c1c969ee5565fce4d6cbcbf19.