first/last name instead ofj ust name, fix og migration instead of updating in second file sqlite issue

This commit is contained in:
2026-01-26 23:31:29 -08:00
parent ea1cb8cd29
commit 348665deb8
15 changed files with 74 additions and 94 deletions

View File

@@ -90,7 +90,6 @@ class ContactUsComponent extends Component {
'contactUsFormSubmission' => $contactUsFormSubmission,
], $this->getController());
$result = $event->getResult();
Log::debug(print_r('$result', true));
Log::debug(print_r($result, true));
if ($result instanceof EntityInterface) {
@@ -104,15 +103,13 @@ class ContactUsComponent extends Component {
if ($contactUsFormSubmissionSaved) {
return $this->_afterFormSaved($contactUsFormSubmissionSaved);
}
// @TODO contact us form submission failed - handle here
}
if ($event->isStopped()) {
return $this->getController()->redirect($event->getResult());
}
if (!$this->getController()->getRequest()->is('post')) {
if (!$postData) {
return;
}

View File

@@ -45,7 +45,7 @@ class ContactUsFormSubmissionsMailer extends Mailer {
*/
protected function backend(ContactUsFormSubmission $contactUsFormSubmission, array $options = []) {
$subject = __d('cake_contact_us', 'Contact Us Form Submitted');
$name = isset($contactUsFormSubmission->name) ? ' by ' . $contactUsFormSubmission->name : '';
$name = isset($contactUsFormSubmission->full_name) ? ' by ' . $contactUsFormSubmission->full_name : '';
$to = Configure::readOrFail('ContactUs.email.backend.to');
$cc = Configure::read('ContactUs.email.backend.cc', []);
@@ -62,7 +62,7 @@ class ContactUsFormSubmissionsMailer extends Mailer {
if ($cc) {
$cc = !is_array($cc) ? [$cc] : $cc;
$this->setCc($to);
$this->setCc($cc);
}
if ($bcc) {
$bcc = !is_array($bcc) ? [$bcc] : $bcc;

View File

@@ -11,7 +11,8 @@ use Cake\ORM\Entity;
* @property string $id
* @property \Cake\I18n\DateTime $submitted_at
* @property string $client_ip
* @property string $name
* @property string|null $first_name
* @property string|null $last_name
* @property string|null $email
* @property string|null $contact_subject
* @property string $message
@@ -32,7 +33,8 @@ class ContactUsFormSubmission extends Entity {
protected array $_accessible = [
'submitted_at' => true,
'client_ip' => true,
'name' => true,
'first_name' => true,
'last_name' => true,
'email' => true,
'contact_subject' => true,
'message' => true,
@@ -40,4 +42,11 @@ class ContactUsFormSubmission extends Entity {
'backend_email_sent' => true,
];
/**
* @return string
*/
protected function _getFullName(): string {
return $this->get('first_name') . ' ' . $this->get('last_name');
}
}

View File

@@ -46,7 +46,7 @@ class ContactUsFormSubmissionsTable extends Table {
parent::initialize($config);
$this->setTable('contact_us_form_submissions');
$this->setDisplayField('name');
$this->setDisplayField('email');
$this->setPrimaryKey('id');
}
@@ -69,10 +69,15 @@ class ContactUsFormSubmissionsTable extends Table {
->allowEmptyString('client_ip');
$validator
->scalar('name')
->maxLength('name', 255)
->requirePresence('name', 'create')
->notEmptyString('name');
->scalar('first_name')
->maxLength('first_name', 255)
->requirePresence('first_name', 'create')
->notEmptyString('first_name');
$validator
->scalar('last_name')
->maxLength('last_name', 255)
->allowEmptyString('last_name');
// email
$validator->email('email');