Skip to content

Commit bf5260e

Browse files
committed
docs: add comments in code
1 parent 70f5d2c commit bf5260e

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • user_guide_src/source/tutorial/create_news_items

user_guide_src/source/tutorial/create_news_items/002.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,22 @@ public function create()
1212
{
1313
helper('form');
1414

15+
// Checks whether the form is submitted.
1516
if (strtolower($this->request->getMethod()) !== 'post') {
16-
// Returns the form.
17+
// The form is not submitted, so returns the form.
1718
return view('templates/header', ['title' => 'Create a news item'])
1819
. view('news/create')
1920
. view('templates/footer');
2021
}
2122

2223
$post = $this->request->getPost(['title', 'body']);
2324

25+
// Checks whether the submitted data passed the validation rules.
2426
if (! $this->validateData($post, [
2527
'title' => 'required|min_length[3]|max_length[255]',
2628
'body' => 'required|min_length[10]|max_length[5000]',
2729
])) {
28-
// Returns the form.
30+
// The validation fails, so returns the form.
2931
return view('templates/header', ['title' => 'Create a news item'])
3032
. view('news/create')
3133
. view('templates/footer');

0 commit comments

Comments
 (0)