CakePHP validation : at least one field must be filled
Sometimes we want users to fill at least one field. Lets say user must fill either customer name or their organization name. This can be achieved in CakePHP as follows. In model function beforeValidate($validate=NULL){ $validate = false; if(!empty($this->data[‘Customer’][‘name’])){ $validate = true; } if(!empty($this->data[‘Customer’][‘organization’])){ $validate = true; } return […]