File tree Expand file tree Collapse file tree
user_guide_src/source/tutorial/create_news_items Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ' );
You can’t perform that action at this time.
0 commit comments