CUSTOM CAKEPHP 3.X
InstalaĆ§Ć£o
<?php
Plugin::load("JCustomCakephp3");
Como usar
Add no Model:, (*1)
<?php
class PostsTable extends Table
{
public function initialize($config = [])
{
$this->addBehavior("JCustomCakephp3.ConvertDate");
}
}
ou, (*2)
<?php
class PostsTable extends Table
{
public function initialize($config = [])
{
$this->addBehavior("JCustomCakephp3.ConvertDate", ['fild_name1', 'fild_name2']);
}
}
2. ValidaĆ§Ć£o de dados brasileiros.
Add no Model no mƩtodo validationDefault():, (*3)
<?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, (*4)