public function index() { $contact = new ContactForm(); if ($this->request->is('post')) { if ($contact->execute($this->request->data)) { $this->Flash->success('Order submitted successfully and its value is ' . $contact->getPrice()); } else { $contact->setErrors(["email" => ["_required" => "Your email is required"]]); $this->Flash->error('There was a problem submitting your form.'); } } $this->set('contact', $contact); }
public function index() { $contact = new ContactForm(); $contact->setErrors(["email" => ["_required" => "Your email is required"]]); if ($this->request->is('post')) { if ($contact->execute($this->request->data)) { $this->Flash->success('We will get back to you soon.'); } else { echo $this->request->data['body']; //$this->Flash->error('There was a problem submitting your form.'); } } if ($this->request->is('get')) { //Values from the User Model e.g. $this->request->data['name'] = 'John Doe'; $this->request->data['email'] = '*****@*****.**'; } $this->set('contact', $contact); }