diff --git a/app/Controller/ObjectsController.php b/app/Controller/ObjectsController.php index f6fd0a3c8..63c4f4e2e 100644 --- a/app/Controller/ObjectsController.php +++ b/app/Controller/ObjectsController.php @@ -133,7 +133,6 @@ class ObjectsController extends AppController { if (empty($template)) { $error = 'No valid template found to edit the object.'; } - // If we have received a POST request if ($this->request->is('post')) { if (isset($this->request->data['request'])) { @@ -195,7 +194,7 @@ class ObjectsController extends AppController { // In the case of a GET request or if the object could not be validated, show the form / the requirement if ($this->_isRest()) { if ($error) { - + return $this->RestResponse->saveFailResponse('objects', 'add', $eventId . '/' . $templateId, $error, $this->response->type()); } else { return $this->RestResponse->viewData($orgs, $this->response->type()); } diff --git a/app/Model/Attribute.php b/app/Model/Attribute.php index 856641630..ff027c9e4 100644 --- a/app/Model/Attribute.php +++ b/app/Model/Attribute.php @@ -659,7 +659,7 @@ class Attribute extends AppModel { } // TODO: add explanatory comment $result = $this->runRegexp($this->data['Attribute']['type'], $this->data['Attribute']['value']); - if (!$result) { + if ($result === false) { $this->invalidate('value', 'This value is blocked by a regular expression in the import filters.'); } else { $this->data['Attribute']['value'] = $result; @@ -683,8 +683,9 @@ class Attribute extends AppModel { } if ($this->data['Attribute']['distribution'] != 4) $this->data['Attribute']['sharing_group_id'] = 0; - // return true, otherwise the object cannot be saved + + if ($this->data['Attribute']['type'] == 'float' && $this->data['Attribute']['value'] == 0) $this->data['Attribute']['value'] = '0.0'; return true; } diff --git a/app/Model/Behavior/RegexpBehavior.php b/app/Model/Behavior/RegexpBehavior.php index 72196578a..d6e3f4878 100644 --- a/app/Model/Behavior/RegexpBehavior.php +++ b/app/Model/Behavior/RegexpBehavior.php @@ -10,7 +10,7 @@ class RegexpBehavior extends ModelBehavior { private $__allRegexp = array(); - public $excluded_types = array('sigma'); + public $excluded_types = array('sigma', 'float'); public function setup(Model $model, $config = null) { $regexp = new Regexp();