use the TrimBehavior on all inputable models.
pull/63/head
noud 2012-11-29 09:35:57 +01:00
parent 8a9783400a
commit eff2f77126
7 changed files with 19 additions and 17 deletions

View File

@ -19,7 +19,7 @@ class Attribute extends AppModel {
'userModel' => 'User',
'userKey' => 'user_id',
'change' => 'full'
),// 'Trim' => array('fields' => array('value'))
), 'Trim' // => array('fields' => array('value'))
);
/**

View File

@ -23,6 +23,19 @@ class TrimBehavior extends ModelBehavior {
$this->settings[$Model->alias], (array)$settings);
}
/**
*
* @param $options
*/
public function beforeValidate(Model $Model, $options = array()) {
//parent::beforeValidate();
// process some..
$this->trimStringFields($Model);
return true;
}
/**
* Trim String Fields
*

View File

@ -14,7 +14,7 @@ class Event extends AppModel {
'userModel' => 'User',
'userKey' => 'user_id',
'change' => 'full'
));
), 'Trim');
/**
* Display field

View File

@ -51,7 +51,7 @@ class Group extends AppModel {
*
* @var unknown_type
*/
public $actsAs = array('Acl' => array('type' => 'requester'), 'MagicTools.OrphansProtectable');
public $actsAs = array('Acl' => array('type' => 'requester'), 'MagicTools.OrphansProtectable', 'Trim');
/**
* TODO ACL: 2: hook Group into CakePHP ACL system (so link to aros)

View File

@ -104,19 +104,6 @@ class Server extends AppModel {
),
);
/**
*
* @param $options
*/
public function beforeValidate($options = array()) {
parent::beforeValidate();
// process some..
$this->trimStringFields();
return true;
}
public function isOwnedByOrg($serverid, $org) {
return $this->field('id', array('id' => $serverid, 'org' => $org)) === $serverid;
}

View File

@ -228,7 +228,7 @@ class User extends AppModel {
'userModel' => 'User',
'userKey' => 'user_id',
'change' => 'full'
)
), 'Trim'
);
/**

View File

@ -20,6 +20,8 @@ class Whitelist extends AppModel {
*/
public $displayField = 'name';
public $actsAs = array('Trim');
/**
* Validation rules
*