fix: Ugly fix for the float issues

pull/2628/head
iglocska 2017-11-08 18:55:13 +01:00
parent a096449631
commit 396eecd242
3 changed files with 5 additions and 5 deletions

View File

@ -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());
}

View File

@ -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;
}

View File

@ -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();