Skip to content

Commit 075d2b3

Browse files
authored
Merge pull request #5348 from kenjis/fix-docs-tutorial
docs: improve Tutorial
2 parents ab3982f + c0fedce commit 075d2b3

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

user_guide_src/source/tutorial/create_news_items.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ the slug from our title in the model. Create a new view at
3333

3434
<h2><?= esc($title) ?></h2>
3535

36+
<?= session()->getFlashdata('error') ?>
3637
<?= service('validation')->listErrors() ?>
3738

3839
<form action="/news/create" method="post">
@@ -47,10 +48,15 @@ the slug from our title in the model. Create a new view at
4748
<input type="submit" name="submit" value="Create news item" />
4849
</form>
4950

50-
There are probably only two things here that look unfamiliar. The
51-
``service('validation')->listErrors()`` function is used to report
52-
errors related to form validation. The ``csrf_field()`` function creates
53-
a hidden input with a CSRF token that helps protect against some common attacks.
51+
There are probably only three things here that look unfamiliar.
52+
53+
The ``<?= session()->getFlashdata('error') ?>`` function is used to report
54+
errors related to CSRF protection.
55+
56+
The ``service('validation')->listErrors()`` function is used to report
57+
errors related to form validation.
58+
59+
The ``csrf_field()`` function creates a hidden input with a CSRF token that helps protect against some common attacks.
5460

5561
Go back to your ``News`` controller. You're going to do two things here,
5662
check whether the form was submitted and whether the submitted data

user_guide_src/source/tutorial/static_pages.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ code.
3939

4040
namespace App\Controllers;
4141

42-
use CodeIgniter\Controller;
43-
44-
class Pages extends Controller
42+
class Pages extends BaseController
4543
{
4644
public function index()
4745
{
@@ -66,7 +64,7 @@ displays the CodeIgniter welcome page.
6664
Both are *technically* a function. But when you create a function in a class,
6765
it's called a method.
6866

69-
The ``Pages`` class is extending the
67+
The ``Pages`` class is extending the ``BaseController`` class that extends the
7068
``CodeIgniter\Controller`` class. This means that the new Pages class can access the
7169
methods and variables defined in the ``CodeIgniter\Controller`` class
7270
(**system/Controller.php**).

0 commit comments

Comments
 (0)