fixes event with no attributes in REST request

pull/61/head
Christophe Vandeplas 2012-05-04 12:44:27 +02:00
parent e1189e576a
commit 03ad7d3acd
1 changed files with 8 additions and 6 deletions

View File

@ -132,12 +132,14 @@ class EventsController extends AppController {
}
// Workaround for different structure in XML/array than what CakePHP expects
if (is_numeric(implode(array_keys($this->request->data['Event']['Attribute']), ''))) {
// normal array of multiple Attributes
$this->request->data['Attribute'] = $this->request->data['Event']['Attribute'];
} else {
// single attribute
$this->request->data['Attribute'][0] = $this->request->data['Event']['Attribute'];
if (is_array($this->request->data['Event']['Attribute'])) {
if (is_numeric(implode(array_keys($this->request->data['Event']['Attribute']), ''))) {
// normal array of multiple Attributes
$this->request->data['Attribute'] = $this->request->data['Event']['Attribute'];
} else {
// single attribute
$this->request->data['Attribute'][0] = $this->request->data['Event']['Attribute'];
}
}
unset($this->request->data['Event']['Attribute']);
unset($this->request->data['Event']['id']);