Typo3 9.5 prefill form field with get parameter

风格不统一 提交于 2020-04-14 07:39:09

问题


I use TYPO3 system extension "form" and want to prefill an input field with a GET parameter.

This TYPO3 8.7. Form prefill input field is working, but only is no_cache=1. Is there another solution without deactivate the whole cache?

Thanks david


回答1:


You can disable the cache of the content column of your form page, for example:

lib.content = COA
lib.content{
    10 < styles.content.get
}
[page["uid"] == 512]
    lib.content = COA_INT
[global]



回答2:


Yes, you can but you need to create HOOK.

This is described in the documentation

For example, the HOOK

/**
 * @param \TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface $renderable
 * @return void
 */
public function initializeFormElement(\TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface $renderable)
{
    if ($renderable->getUniqueIdentifier() === 'contactForm-text-1') {
        $renderable->setDefaultValue('foo');
    }
}

And the connect the hook

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['initializeFormElement'][<useATimestampAsKeyPlease>]
    = \VENDOR\YourNamespace\YourClass::class;

Please, read the documentation for "Form framework".

I did it and get results what I need.



来源:https://stackoverflow.com/questions/59022188/typo3-9-5-prefill-form-field-with-get-parameter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!