Update api Zone Saving. Fixes #3037
This commit is contained in:
parent
74d2ba56db
commit
2cd9c8e232
|
@ -115,6 +115,7 @@ class ZonesController extends AppController {
|
|||
if ( !$this->Zone->exists($id) ) {
|
||||
throw new NotFoundException(__('Invalid zone'));
|
||||
}
|
||||
$message = '';
|
||||
if ( $this->request->is(array('post', 'put')) ) {
|
||||
global $user;
|
||||
$canEdit = (!$user) || $user['Monitors'] == 'Edit';
|
||||
|
@ -123,14 +124,15 @@ class ZonesController extends AppController {
|
|||
return;
|
||||
}
|
||||
if ( $this->Zone->save($this->request->data) ) {
|
||||
return $this->flash(__('The zone has been saved.'), array('action' => 'index'));
|
||||
$message = 'The zone has been saved.';
|
||||
} else {
|
||||
$message = 'Error ' . print_r($this->Zone->invalidFields());
|
||||
}
|
||||
} else {
|
||||
$options = array('conditions' => array('Zone.' . $this->Zone->primaryKey => $id));
|
||||
$this->request->data = $this->Zone->find('first', $options);
|
||||
}
|
||||
$monitors = $this->Zone->Monitor->find('list');
|
||||
$this->set(compact('monitors'));
|
||||
$this->set(array(
|
||||
'message' => $message,
|
||||
'_serialize' => array('message')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,19 +41,15 @@ class Zone extends AppModel {
|
|||
//array('naturalNumber'),
|
||||
'message' => 'Zones must have a valid MonitorId',
|
||||
'allowEmpty' => false,
|
||||
'required' => true,
|
||||
//'last' => false, // Stop validation after this rule
|
||||
//'on' => 'create', // Limit validation to 'create' or 'update' operations
|
||||
),
|
||||
'Name' => array(
|
||||
'required' => array(
|
||||
//'on' => 'create',
|
||||
'rule' => 'notBlank',
|
||||
'message' => 'Zone Name must be specified for creation',
|
||||
'required' => true,
|
||||
),
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
//The Associations below have been created with all possible keys, those that are not needed can be removed
|
||||
|
|
Loading…
Reference in New Issue