Skip to content

Commit 64c9ec0

Browse files
authored
Merge pull request #7017 from kenjis/docs-update-tutorial
docs: update tutorial
2 parents 0bfaa0e + 07af7a4 commit 64c9ec0

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

user_guide_src/source/tutorial/create_news_items.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ Most helper functions require the helper to be loaded before use.
9090
Next, we check if we deal with the **POST** request with the
9191
:doc:`IncomingRequest <../incoming/incomingrequest>` object ``$this->request``.
9292
It is set in the controller by the framework.
93-
If the HTTP method is not POST, that is it is GET,
93+
The :ref:`IncomingRequest::is() <incomingrequest-is>` method checks the type of the request.
94+
Since the route for **create()** endpoint handles both: **GET** and **POST** requests we can safely assume that if the request is not POST then it is a GET type.
9495
the form is loaded and returned to display.
9596

9697
Then, we get the necessary items from the POST data by the user and set them in the ``$post`` variable.

user_guide_src/source/tutorial/create_news_items/002.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function create()
1313
helper('form');
1414

1515
// Checks whether the form is submitted.
16-
if (strtolower($this->request->getMethod()) !== 'post') {
16+
if (! $this->request->is('post')) {
1717
// The form is not submitted, so returns the form.
1818
return view('templates/header', ['title' => 'Create a news item'])
1919
. view('news/create')
@@ -24,8 +24,8 @@ public function create()
2424

2525
// Checks whether the submitted data passed the validation rules.
2626
if (! $this->validateData($post, [
27-
'title' => 'required|min_length[3]|max_length[255]',
28-
'body' => 'required|min_length[10]|max_length[5000]',
27+
'title' => 'required|max_length[255]|min_length[3]',
28+
'body' => 'required|max_length[5000]|min_length[10]',
2929
])) {
3030
// The validation fails, so returns the form.
3131
return view('templates/header', ['title' => 'Create a news item'])

0 commit comments

Comments
 (0)