Interview Questions

What is the defference between required and notEmpty in cakephp?

CakePHP Interview Questions and Answers


(Continued from previous question...)

What is the defference between required and notEmpty in cakephp?

In cakephp,various validations rules are used to validate your forms like required, min length, maxlength etc.Such validation rules makes form handling much easier. But the thing we are going to discuss here is the difference between required and nonEmpty() rules. The use of both is quite easy to understand, but the interesting thing is difference between them

nonEmpty simply check the Present Data validation, on the other end by using required=>true you are telling cakephp that on submission of the form this field must be there in the data array. If you remove the field having the required=>true validation and submit the form then it will throw the validation error.

(Continued on next question...)

Other Interview Questions