Reputation: 627
I got a problem with the standalone view in extbase.
The problem is that when the view is generated with the standalone view the forms are not right. If I use the default generator the form looks like that:
<form role="form" name="user" id="validateEmailForm" action="index.php?id=2&tx_registration_userregistration%5Buser%5D=&tx_registration_userregistration%5Baction%5D=validateEmail&tx_registration_userregistration%5Bcontroller%5D=User&cHash=b608ba14aff3a034be5e58a0402b96c0" method="post">
<div>
<input name="tx_registration_userregistration[__referrer][@extension]" value="Registration" type="hidden">
<input name="tx_registration_userregistration[__referrer][@vendor]" value="Whmcs" type="hidden">
<input name="tx_registration_userregistration[__referrer][@controller]" value="User" type="hidden">
<input name="tx_registration_userregistration[__referrer][@action]" value="test" type="hidden">
<input name="tx_registration_userregistration[__referrer][arguments]" value="YToyOntzOjY6ImFjdGlvbiI7czo0OiJ0ZXN0IjtzOjEwOiJjb250cm9sbGVyIjtzOjQ6IlVzZXIiO30=0fea5b97636b178cebbb4da9ed487d5e77f205ae" type="hidden">
<input name="tx_registration_userregistration[__trustedProperties]" value="a:1:{s:4:"user";a:2:{s:12:"eMailAddress";i:1;s:13:"eMailVerified";i:1;}}bbc1e3377150a6976a7dbec4197d034951d29ef0" type="hidden">
</div>
<div class="form-group">
<label>E-Mail Adresse</label>
<input class="form-control" name="tx_registration_userregistration[user][eMailAddress]" type="text">
</div>
<div class="form-group">
<label>Verifizierungs Code</label>
<input class="form-control" name="tx_registration_userregistration[user][eMailVerified]" type="text">
</div>
<button type="button" class="btn btn-primary" onclick="validateEmailForm();">Bestätigen</button>
<input class="small button" name="" value="Bestaetigen!" type="submit">
<a class="small button" href="index.php?id=2&tx_registration_userregistration%5Baction%5D=resendValidationCodeForm&tx_registration_userregistration%5Bcontroller%5D=User&cHash=89f3a9885d968a1cc58b78afeb462156">Code erneut anfordern</a>
</form>
If I use the standalone view generator, the form looks like that:
<form role="form" name="user" id="validateEmailForm" action="index.php?id=2&tx_registration_%5Buser%5D=&tx_registration_%5Baction%5D=validateEmail&tx_registration_%5Bcontroller%5D=Standard&cHash=1342195ecb09bfaa3eaaed53b5b6ca94" method="post">
<div>
<input name="__referrer[@extension]" value="Registration" type="hidden">
<input name="__referrer[@controller]" value="Standard" type="hidden">
<input name="__referrer[@action]" value="index" type="hidden">
<input name="__referrer[arguments]" value="YTowOnt932be2d0043f353815075d39b8a8dcae00ef10469" type="hidden">
<input name="__trustedProperties" value="a:2:{s:4:"user";a:2:{s:12:"eMailAddress";i:1;s:13:"eMailVerified";i:1;}i:0;i:1;}34e733be32be90328d34d6e089e19ec1e4f4a54a" type="hidden">
</div>
<div class="form-group">
<label>E-Mail Adresse</label>
<input class="form-control" name="user[eMailAddress]" type="text">
</div>
<div class="form-group">
<label>Verifizierungs Code</label>
<input class="form-control" name="user[eMailVerified]" type="text">
</div>
<button type="button" class="btn btn-primary" onclick="validateEmailForm();">Bestätigen</button>
<input class="small button" name="" value="Bestaetigen!" type="submit">
<a class="small button" href="index.php?id=2&tx_registration_%5Baction%5D=resendValidationCodeForm&tx_registration_%5Bcontroller%5D=Standard&cHash=0d47678ecec458d7283b92e15bd9d1d4">Code erneut anfordern</a>
</form>
As you can see, for example at the input elements in the name tag "tx_registration_userregistration" is missing, and the controller cannot work with that.
The way I generate the code with the standalone view generator is:
$View = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
$extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$templateRootPath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($extbaseFrameworkConfiguration['view']['templateRootPath']);
$templatePathAndFilename = $templateRootPath . 'tabControl/' . $templateName . '.html';
$View->setTemplatePathAndFilename($templatePathAndFilename);
$View->assignMultiple($variables);
$renderedView = $View->render();
return $renderedView;
Does anyone know the problem and may know how I can fix this?
Upvotes: 1
Views: 942
Reputation: 55798
Action's view uses controller's context, but standalone view has no any context by default. You need to pass it yourself i.e. right after creating the view object:
$View = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
$View->setControllerContext($this->controllerContext);
Upvotes: 4