File tree Expand file tree Collapse file tree
user_guide_src/source/tutorial Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -106,11 +106,22 @@ You're going to do three things here:
106106
107107The code above adds a lot of functionality.
108108
109+ Retrieve the Data
110+ ^^^^^^^^^^^^^^^^^
111+
112+ First, we use the :doc: `IncomingRequest <../incoming/incomingrequest >`
113+ object ``$this->request ``, which is set in the controller by the framework.
114+
115+ We get the necessary items from the **POST ** data by the user and set them in the
116+ ``$data `` variable.
117+
109118Validate the Data
110119^^^^^^^^^^^^^^^^^
111120
112- You'll use the Controller-provided helper function :ref: `validate() <controller-validate >` to validate the submitted data.
121+ Next, you'll use the Controller-provided helper function
122+ :ref: `validateData() <controller-validatedata >` to validate the submitted data.
113123In this case, the title and body fields are required and in the specific length.
124+
114125CodeIgniter has a powerful validation library as demonstrated
115126above. You can read more about the :doc: `Validation library <../libraries/validation >`.
116127
Original file line number Diff line number Diff line change @@ -13,8 +13,10 @@ public function create()
1313 {
1414 helper ('form ' );
1515
16+ $ data = $ this ->request ->getPost (['title ' , 'body ' ]);
17+
1618 // Checks whether the submitted data passed the validation rules.
17- if (! $ this ->validate ( [
19+ if (! $ this ->validateData ( $ data , [
1820 'title ' => 'required|max_length[255]|min_length[3] ' ,
1921 'body ' => 'required|max_length[5000]|min_length[10] ' ,
2022 ])) {
You can’t perform that action at this time.
0 commit comments