How to give validation for drop down box and text box min length in cakephp3.6.7

how to give validation for drop down box in cakephp3.6.7 please help me

thanks & regards

Do you have read this manual?

Maybe this example can help:
Table: users;
Fields : id, username, role_id;

->notEmpty(‘name’, ‘Please fill this field’);

	->notEmpty('role_id', 'Please select this options');

Sometime, I do like this for dropdown to make default empty value.
	echo $this->Form->input('role_id',['options'=>$roles, **'empty'=>'(Select)'**]);

sorry about my language :grin:

thanks yar,
but which file i’ll put that $validator variable…?


Please check above file in your project if you baked your models.


I think you should use this for get full code generated by cake bake.

bin/cake bake all [tables name]

bin/cake bake all users

thank you guyzzzz…,

but i cant fetch multiple checkbox value from database

it stored like (1,3) in database but fetching not showing using implode and explode functions in cakephp3.6.7

plz help me

I think this the basic idea.
You can found it at

$selected = [1, 3];
$options = [1, 2, 3, 4, 5];

echo $this->Form->select(
        'multiple' => true,
        'value' => $selected