I have created a car extension which contains a list view and a detail view. The detail view also contains a contact form. This extensions works fine with realURL disabled, but for SEO friendly urls I have enabled and configured realURL so I got the following behaviour for my urls:
list view
domain.de/index.php?id=3 -> domain.de/cars/
detail view
domain.de/index.php?id=38 -> domain.de/cars/details/
detail view + get parameter car
domain.de/index.php?id=38&car=200 -> domain.de/cars/details/{brand-model}/
So the URL rewriting is working correctly and my extension anchors from list view to detail view also works as expected, but my contact form on the detail view is not working anymore.
Fluid markup of my form
<f:form action="send" method="post" name="request" section="form" object="{request}">
<fieldset>
<label>Salutation<span class="required">*</span>
<f:render partial="FormErrors" arguments="{field: 'request.salutation'}" />
</label>
<f:form.hidden property="salutation" />
<label>
<f:form.radio property="salutation" value="female" />Frau
</label>
<label>
<f:form.radio property="salutation" value="male" />Herr
</label>
</fieldset>
<fieldset>
<label for="name">Name<span class="required">*</span>
<f:render partial="FormErrors" arguments="{field: 'request.name'}" />
</label>
<f:form.textfield property="name" />
</fieldset>
....
<fieldset>
<f:form.submit class="button" name="send" value="Send" />
</fieldset>
</f:form>
If I inspect this form with developer tools I got the following markup:
with realURL enabled
<form method="post" name="request" action="cars/details/?tx_foxcars_p1%5Baction%5D=send&cHash=f654ce4fb67a5b5c636508675c18d4c3#form">
with realURL disabled
<form method="post" name="request" action="index.php?id=38&tx_foxcars_p1%5Baction%5D=send&cHash=f654ce4fb67a5b5c636508675c18d4c3#form">
I think that is ok, but if I submit the form with realURL enabled I got the content of my 404 page. With realURL disabled it is working as expected.
My sendAction looks as follows:
public function sendAction(\Fox\FoxCars\Domain\Model\Request $request)
{
$fromEmail = $request->getEmail();
$fromName = $request->getName();
$toEmail = $this->settings['senderEmail'];
$toName = $this->settings['senderName'];
$subject = $this->settings['subject'];
$body = $request->getBody();
$mail = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
$mail->setFrom(array($fromEmail => $fromName));
$mail->setTo(array($toEmail => $toName));
$mail->setSubject($subject);
$mail->setBody($body, 'text/html');
$mail->send();
if ($mail->isSent()) {
$this->redirect('send', null, null, null, $this->settings['confirmPageId']);
}
}
But it seems that this action will not be executed if realURL is enabled.
My realURL configuration looks as follows:
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'] = array(
'_DEFAULT' => array(
'init' => array(
'enableCHashCache' => true,
'appendMissingSlash' => 'ifNotFile,redirect',
'adminJumpToBackend' => true,
'enableUrlDecodeCache' => true,
'enableUrlEncodeCache' => true,
'respectSimulateStaticURLs' => false,
'emptyUrlReturnValue' => '/',
),
'pagePath' => array(
'type' => 'user',
'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
'spaceCharacter' => '-',
'languageGetVar' => 'L',
'rootpage_id' => '1',
),
'fileName' => array(
'defaultToHTMLsuffixOnPrev' => 0,
'acceptHTMLsuffix' => 1,
'index' => array(
'print' => array(
'keyValues' => array(
'type' => 98,
),
),
),
),
'fixedPostVars' => array(
'carsDetailConfiguration' => array(
array(
'GETvar' => 'car',
'lookUpTable' => array(
'table' => 'tx_foxcars_domain_model_car',
'id_field' => 'uid',
'alias_field' => "CONCAT(brand, '-', model)",
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-'
),
'languageGetVar' => 'L',
'languageExceptionUids' => '',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent'
)
)
),
'38' => 'carsDetailConfiguration',
'newsDetailConfiguration' => array(
array(
'GETvar' => 'tx_news_pi1[news]',
'lookUpTable' => array(
'table' => 'tx_news_domain_model_news',
'id_field' => 'uid',
'alias_field' => 'title',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-',
),
),
),
),
'35' => 'newsDetailConfiguration',
),
'postVarSets' => array(
'_DEFAULT' => array(
'news' => array(
0 => array(
'GETvar' => 'tx_news_pi1[news]',
'lookUpTable' => array(
'table' => 'tx_news_domain_model_news',
'id_field' => 'uid',
'alias_field' => 'title',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-',
),
),
),
),
'cars' => array(
0 => array(
'GETvar' => 'car',
'lookUpTable' => array(
'table' => 'tx_foxcars_domain_model_car',
'id_field' => 'uid',
'alias_field' => "CONCAT(brand, '-', model)",
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-',
),
),
),
),
),
),
),
);
Maybe is there a misconfiguration with realURL? So realURL expect the get parameter "car", but only get the send action? So car is missing and not found -> 404?
Hope you can help me :)
I forgot to add
additionalParams="{car: car}"
to my form. So I changed
<f:form action="send" method="post" name="request" section="form" object="{request}">
to
<f:form action="send" additionalParams="{car: car}" method="post" name="request" section="form" object="{request}">
and it is working now :).