Hey folks!
since an update (I think), I have a problem receiving post-data. $this->request->data
or $this->request->getData()
is empty. No matter, where I check this data. I checked it in “AppController initialize and beforeFilter” and also in “…Controller initialize and beforeFilter”. Maybe, I am accessing it in a wrong way, because the data gets saved. It is a bit strange, because accessing postdata worked all the time.
When I debug $this->request->data
and $this->request->getData()" and
$this->requestand
$this`, I could never find my data what I posted. The array “data” is empty in request.
Originally, I wanted to check if “created” and “modified” are set via postData. If so, I want to unset/delete these values, so that cakephp handles it hisself via timestamp behavior. This only applies for the REST-Api I created.
Here is my corresponding code.
//AppController (API)
public function beforeFilter(Event $event) {
$this->Auth->allow(['token']);
if(array_key_exists("created", $this->request->data)) {
if ( (substr($this->request->data["created"], 0, 1) == "0") || ($this->request->data["created"] == "null") ) {
unset($this->request->data["created"]);
}
}
if(array_key_exists("modified", $this->request->data)) {
if ( (substr($this->request->data["modified"], 0, 1) == "0") || ($this->request->data["modified"] == "null") ) {
unset($this->request->data["modified"]);
}
}
debug($this->request->data);
}
Thanks in advance!