handcode / yii2-active-record-typecast-behavior
TypeCast Behavior for yii2 ActiveRecords which can be used to ensure attribute types match db schema types
Package info
github.com/handcode/yii2-active-record-typecast-behavior
Type:yii2-extension
pkg:composer/handcode/yii2-active-record-typecast-behavior
Requires
- yiisoft/yii2: ~2.0.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-13 19:59:53 UTC
README
This behavior can be used to typecast yii2 ActiveRecord attribute values according to the db->schema types
Why?
To automate the filters required to solve the "int-cols are always dirty if submitted via http" problem.
see:
config
the attribute typecast is done by calling \yii\validators\FilterValidator with defined filter callback according to db schema phpType
all attributes with types not defined in the typeFilter array of the behavior will be ignored.
The default typeFilter definition is:
public $typeFilter = [ 'integer' => 'intval', 'float' => 'floatval' ];