forked from cakephp/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cakephp#4391 from cakephp/psr7-request
Update documentation for PSR7 requests
- Loading branch information
Showing
22 changed files
with
139 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,7 +82,7 @@ and validate request data:: | |
{ | ||
$contact = new ContactForm(); | ||
if ($this->request->is('post')) { | ||
if ($contact->execute($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.'); | ||
|
@@ -97,13 +97,13 @@ In the above example, we use the ``execute()`` method to run our form's | |
accordingly. We could have also used the ``validate()`` method to only validate | ||
the request data:: | ||
|
||
$isValid = $form->validate($this->request->data); | ||
$isValid = $form->validate($this->request->data()); | ||
Setting Form Values | ||
=================== | ||
|
||
In order to set the values for the fields of a modelless form, one can define | ||
the values using ``$this->request->data``, like in all other forms created by the FormHelper:: | ||
the values using ``$this->request->data()``, like in all other forms created by the FormHelper:: | ||
|
||
// In a controller | ||
namespace App\Controller; | ||
|
@@ -117,23 +117,23 @@ the values using ``$this->request->data``, like in all other forms created by th | |
{ | ||
$contact = new ContactForm(); | ||
if ($this->request->is('post')) { | ||
if ($contact->execute($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.'); | ||
} | ||
} | ||
|
||
if ($this->request->is('get')) { | ||
//Values from the User Model e.g. | ||
$this->request->data['name'] = 'John Doe'; | ||
$this->request->data['email'] = '[email protected]'; | ||
// Values from the User Model e.g. | ||
$this->request->data('name', 'John Doe'); | ||
$this->request->data('email','[email protected]'); | ||
} | ||
|
||
$this->set('contact', $contact); | ||
} | ||
} | ||
|
||
Values should only be defined if the request method is GET, otherwise | ||
you will overwrite your previous POST Data which might have been incorrect | ||
and not been saved. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.