<?php
Plugin::load("JCustomCakephp3");
Add no Model:
<?php
class PostsTable extends Table
{
public function initialize($config = [])
{
$this->addBehavior("JCustomCakephp3.ConvertDate");
}
}
ou
<?php
class PostsTable extends Table
{
public function initialize($config = [])
{
$this->addBehavior("JCustomCakephp3.ConvertDate", ['fild_name1', 'fild_name2']);
}
}
Add no Model no método validationDefault():
<?php
public function validationDefault(Validator $validator)
{
$validator
->provider('custom', new \JCustomCakephp3\Validation\CustomProvider)
->add('birth', 'valid', ['rule' => 'dateBR', 'provider' => 'custom'])
->requirePresence('birth', 'create')
->notEmpty('birth');
}
Rules:
- dateBR
- datetimeBR
- cnpj
- cpf
- cep
- phone
- cellphone