I'm learning CakePHP 3.X version and I'm really confused about Form validation.
In the documentation (http://book.cakephp.org/3.0/en/core-libraries/form.html) is saying that you need to create a class to validate your form and you have two methods to validate the data.
First method:
protected function _buildSchema(Schema $schema)
{
return $schema;
}
Second method:
protected function _buildValidator(Validator $validator)
{
return $validator;
}
What is the really difference between them?
In the documentation example is saying this:
_buildSchema is used to define the schema data that is used by FormHelper to create an HTML form. You can define field type, length, and precision.
_buildValidator Gets a Cake\Validation\Validator instance that you can attach validators to.
I'm confused because if you look at the examples in the documentation you gonna see that he's validating the input length and things like that in the second method, but in the description of the first method he's saying that you can do that too?
Is it possible to explain to me the really differece between them and show to me an example?
Thanks!