Skip to content

Instantly share code, notes, and snippets.

@vinacode
Created January 9, 2015 04:15
Show Gist options
  • Save vinacode/9e675138b882777d22ab to your computer and use it in GitHub Desktop.
Save vinacode/9e675138b882777d22ab to your computer and use it in GitHub Desktop.
CakePHP 3 contact controller
<?php
namespace App\Controller;
use App\Controller\AppController;
use App\Form\ContactForm;
class ContactController extends AppController
{
public function index()
{
$contact = new ContactForm();
if ($this->request->is('post')) {
// $isValid = $form->validate($this->request->data);
if ($contact->execute($this->request->data)) {
$this->Flash->success('We will get back to you soon.');
} else {
$this->Flash->error('There was a problem submitting your form.');
}
}
$this->set('contact', $contact);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment