M
M
Maxim Grechushnikov2016-04-23 01:29:13
CakePHP
Maxim Grechushnikov, 2016-04-23 01:29:13

CakePHP: beforeValidate is not called. For what reason?

There is a project. Everything worked. Asked to add a new field. Added in the form and in the database. I did not touch the controller and model code.
The fields are being filled. But I got a strange error.
in the beforeValidate method of the model I need, there is the generation of the slug attribute. and it stopped generating. by poke came to

public function beforeValidate($options = array()) {die('<pre>'.print_r(array(__FILE__, __LINE__, __METHOD__, __CLASS__),true));

and it turned out neither when creating nor updating the record, this method is called.
I myself have been working in Yii for many years, I understand how it works. But I can't figure out why this is happening. Maybe I don't know what? Maybe something needs to be written somewhere? maybe there are some internal logs?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mordawar, 2016-04-24
@maxyc_webber

Make sure you do save with validation. Otherwise, the beforeValidate method is simply not called.

M
mitaichik, 2016-04-23
@mitaichik

There are many options - install XDebug and see what happens. This is more professional than the poke method.
Perhaps you have overridden the save method?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question