There are two actions in my Controller, formAction()
and sendOrderAction()
. The latter should process a domain object Order
, which is validated on submitting the formAction
. This works as expected. But when the validation fails, I also want to access some properties the object might have in the formAction
. But unfortunately, the object is always null when its validation failed (even if I use @TYPO3CMSExtbaseAnnotationIgnoreValidation
). Is there any other way to access its properties?
/**
* form action
*
* @param Order $order
* @TYPO3CMSExtbaseAnnotationIgnoreValidation("order")
*
* @return void
*/
public function formAction(Order $order = null): void
{
// Here, I want to access possible properties of $order, in case the validation failed, for example:
DebuggerUtility::var_dump($order->getFirstName());
// Doesn't work, the param $order is always null
}
/**
* sendOrder action
*
* @param Order $order
*
* @return bool
*/
public function sendOrderAction(Order $order): void
{
// Do stuff with $order when validation succeeds
}
I also tried accessing the arguments with $this->arguments
, but that didn’t work either. Can anyone help?
I found a solution that works for me:
/**
* form action
*
* @return void
*/
public function formAction(): void
{
DebuggerUtility::var_dump($this->request->getParsedBody()['tx_myext_plugin']['order']['firstName']);
}