Class JSONFieldsDefaultValuesBehavior
Enables transparent serialization and storage of array objects in database
fields as JSON strings. In contrast to NormalizedJSONFieldsBehavior where JSON
properties default to null, here the transformAttributes array is treated as an
associative array where the values are used as the default values for each JSON
property. Note that a failure to explicitly define a default value in the
transformAttributes array will result in potentially unexpected behavior (e.g.
array ('<JSON field 0>, <JSON field 1> => <JSON field 1
default value>), here <JSON field 0> would be the default value of a
JSON field called '0').
-
CComponent
-
CBehavior
implements
IBehavior
-
CModelBehavior
-
CActiveRecordBehavior
-
TransformedFieldStorageBehavior
-
JSONFieldsBehavior
-
NormalizedJSONFieldsBehavior
-
JSONFieldsDefaultValuesBehavior
Methods summary
public
type
|
#
fields( mixed $name )
Returns an array defining the expected structure of the JSON-bearing
attribute specified by $name.
Returns an array defining the expected structure of the JSON-bearing
attribute specified by $name.
Parameters
Returns
type
Overrides
|
public
|
#
afterConstruct( CEvent $event )
Responds to CModel::onAfterConstruct event. Override this method and
make it public if you want to handle the corresponding event of the CBehavior::owner owner.
Responds to CModel::onAfterConstruct event. Override this method and
make it public if you want to handle the corresponding event of the CBehavior::owner owner.
Parameters
- $event
CEvent $event event parameter
Overrides
CModelBehavior::afterConstruct()
|
Methods inherited from CActiveRecordBehavior
afterDelete(),
beforeCount(),
beforeDelete(),
beforeFind(),
events()
|
Methods inherited from CModelBehavior
afterValidate(),
beforeValidate()
|
Methods inherited from CBehavior
attach(),
detach(),
getEnabled(),
getOwner(),
setEnabled()
|
Methods inherited from CComponent
__call(),
__get(),
__isset(),
__set(),
__unset(),
asa(),
attachBehavior(),
attachBehaviors(),
attachEventHandler(),
canGetProperty(),
canSetProperty(),
detachBehavior(),
detachBehaviors(),
detachEventHandler(),
disableBehavior(),
disableBehaviors(),
enableBehavior(),
enableBehaviors(),
evaluateExpression(),
getEventHandlers(),
hasEvent(),
hasEventHandler(),
hasProperty(),
raiseEvent()
|
Magic properties inherited from CActiveRecordBehavior
$owner
|
Magic properties inherited from CBehavior
$enabled
|