OiO.lk Blog PHP TYPO3 Forms + Hook interaction
PHP

TYPO3 Forms + Hook interaction


Im currently trying to implement a form in TYPO3 with typo3/cms-forms.

My Form has to be a bit more dynamic, i need to fetch some data from an API and represent it in the form. To achieve that, i thought of using a hook to manipulate the basic structure of my form.

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['initializeFormElement'][1729246696]
    = \SchmelzermedienGmbh\ImApi\Hooks\Forms\FormHook::class;
class FormHook
{
 
    public function initializeFormElement(FormElementInterface $renderable)
    {
        error_log('initialized formElement hook');
        if ($renderable->getIdentifier() === 'text-1') {
            $renderable->setProperty('placeholder', 'somePlaceholderTexts');
        }
    }

This is not working and i already tried different hooks, like beforeRendering, afterBuildingFinished and so on.
My changes to some properties like the placeholder are not getting through and are not getting displayed in the frontend.



You need to sign in to view this answers

Exit mobile version