Task #82615

EXT:form - Add more explanations about the initializeFormElement hook into the docs.

Added by Juan Manuel Vergés Solanas over 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Should have
Category:
Form Framework
Target version:
-
Start date:
2017-09-29
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
8
PHP Version:
7.1
Tags:
Complexity:
Sprint Focus:

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)

#1

Updated by Ralf Zimmermann over 4 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.

#2

Updated by Juan Manuel Vergés Solanas over 4 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'

#3

Updated by Juan Manuel Vergés Solanas over 4 years ago

  • Assignee changed from Juan Manuel Vergés Solanas to Ralf Zimmermann
#4

Updated by Gerrit Code Review over 4 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

#5

Updated by Gerrit Code Review over 4 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

#6

Updated by Ralf Zimmermann over 4 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

#7

Updated by Ralf Zimmermann over 4 years ago

  • Status changed from Needs Feedback to Under Review
#8

Updated by Gerrit Code Review over 4 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

#9

Updated by Ralf Zimmermann over 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
#10

Updated by Benni Mack over 3 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF