Skip to content
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

Automatically register hook for checking UnsubmittableFormDefinition #34

Open
kftw opened this issue Aug 28, 2020 · 0 comments
Open

Automatically register hook for checking UnsubmittableFormDefinition #34

kftw opened this issue Aug 28, 2020 · 0 comments
Assignees

Comments

@kftw
Copy link
Contributor

kftw commented Aug 28, 2020

To use unsubmittable Forms using Tollwerk\TwBase\Domain\Model\UnsubmittableFormDefinition, one has to register a hook for handling that in his own extension:

ext_localconf.php

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form'][] = \Path\To\YourClass:class;

YourClass.php

class YourClass {
   public function afterInitializeCurrentPage(FormRuntime $formRuntime, CompositeRenderableInterface $currentPage = null, CompositeRenderableInterface $lastPage = null, array $requestArguments = []): ?CompositeRenderableInterface
    {
       // Handle unsubmittable forms (filters forms etc.).
       // Important: This condition MUST always be called last inside this function
       if ($formRuntime->getFormDefinition() instanceof UnsubmittableFormDefinition) {
          return $formDefinition->getPageByIndex(0);
       }
    }
 }

Couldn't that be automatically handled by tw_base itself? I see that if you don't need that feature in your particular TYPO3 installation, registering and checking it anyway is a bit of overhead. But needing unsubmittable forms is such a common thing I think it could make sense to let tw_base handle that automatically.

@kftw kftw changed the title Automatically register hook to check for checking UnsubmittableFormDefinition Automatically register hook for checking UnsubmittableFormDefinition Aug 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants