We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Skip Columns on validation

Hi is possible to skip some columns on validation like creator_id, crated_time and so on? I found only possibility how to skip some attributes (onupdate, oncreate, both) but this will exclude these columns from SQL too. So is possible skip some columns or do you plan add this feature to Phalcon?



98.9k
edited Aug '14

When you use skipAttributesOnCreate/skipAttributesOnUpdate they're also not validated: https://github.com/phalcon/cphalcon/blob/2.0.0/phalcon/mvc/model.zep#L1854

Thats what i wrote - skipAttributesOnUpdate, skipAttributesOnCreate, skipAttributes - however documentation says they are skipped from INSERT, UPDATE statement too. So is possible skipAttributes only and keep them in SQL statement?

So looks like there is not currently solution skip validation for some attributes which can be used in SQL statement?

Any hint? This is major issue because columns like creator_id, creator_time are important for audits and I dont want to override anything like beforeValidation because record before validation is dirty and i would like to set create info before SQL insert. However because these columns are not null they must be filled before validation. Any possibility add new functionality to 2.0? In that case I would like to download compiled NTS VC9 version too.



60

\Phalcon\Mvc\Model::setup(array(
'notNullValidations' => false ));

or place call it in Model's initialize using $this->setup(..)