How to return new field from cakephp beforeMarshal -
so have rest api expecting json string containing field, eg, 'status'. need relate string id , have obtained id using beforemarshal in table model:
$query = $status->find() ->where (['status' => 'new']); $id = $query->first(); $data['status_id'] .= $id->id;
problem above, $data['status_id']
not work because 'status_id' not in incoming fields.
how can add 'status_id' $data field, or return beforemarshal, such replaces 'status' string value ?
ie, incoming: {"status": "new"}
, before saving entity, need {"status_id": "2"}
this cakephp v3
Comments
Post a Comment