behaviors\AttributeTypecastBehavior $attributeTypes

$attributeTypes public property

Attribute typecast map in format: attributeName => type. Type can be set via PHP callable, which accept raw value as an argument and should return typecast result. For example:

[
    'amount' => 'integer',
    'price' => 'float',
    'is_active' => 'boolean',
    'date' => function ($value) {
        return ($value instanceof \DateTime) ? $value->getTimestamp(): (int)$value;
    },
]

If not set, attribute type map will be composed automatically from the owner validation rules.

public array $attributeTypes = null
doc_Yii
2016-10-30 16:52:45
Comments
Leave a Comment

Please login to continue.