This commit is contained in:
2025-11-10 22:26:52 -08:00
parent 77f09055c9
commit a659368867
19 changed files with 301 additions and 358 deletions

View File

@@ -70,6 +70,7 @@ class ContactUsComponent extends Component
if ($this->getConfig('requireCaptcha')) {
$this->ContactUsFormSubmissions->addBehavior('Captcha.Captcha');
}
return $this->ContactUsFormSubmissions->newEmptyEntity();
}
@@ -81,7 +82,12 @@ class ContactUsComponent extends Component
if (!isset($postData)) {
$postData = $this->getController()->getRequest()->getData();
}
$postData['client_ip'] = array_key_exists('client_ip', $postData) && $postData['client_ip'] ? $postData['client_ip'] : $this->getController()->getRequest()->clientIp();
$postData['client_ip'] = array_key_exists('client_ip', $postData) && $postData['client_ip'] ?
$postData['client_ip'] :
($this->getConfig('clientIpHeader') ?
$this->getController()->getRequest()->getHeaderLine($this->getConfig('clientIpHeader')) :
$this->getController()->getRequest()->clientIp()
);
$postData['submitted_at'] = DateTime::now();
$event = $this->getController()->dispatchEvent(CakeContactUsPlugin::EVENT_BEFORE_CONTACT_US_FORM_SAVED, [
@@ -119,7 +125,10 @@ class ContactUsComponent extends Component
Log::debug(print_r('$contactUsFormSubmission->getErrors()', true));
Log::debug(print_r($contactUsFormSubmission->getErrors(), true));
}
$contactUsFormSubmissionSaved = $this->ContactUsFormSubmissions->save($contactUsFormSubmission);
if ($contactUsFormSubmissionSaved) {
return $this->_afterFormSaved($contactUsFormSubmissionSaved);
}
@@ -140,7 +149,6 @@ class ContactUsComponent extends Component
protected function _afterFormSaved(EntityInterface $contactUsFormSubmissionSaved)
{
$message = __d('cake_contact_us', 'Message received, thank you. We will be in touch soon.');
$event = $this->getController()->dispatchEvent(CakeContactUsPlugin::EVENT_AFTER_CONTACT_US_FORM_SAVED, [
'contactUsFormSubmission' => $contactUsFormSubmissionSaved,
], $this->getController());