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', 'userModel' => 'User',
'userKey' => 'user_id', 'userKey' => 'user_id',
'change' => 'full' '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); $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 * Trim String Fields
* *

View File

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

View File

@ -51,7 +51,7 @@ class Group extends AppModel {
* *
* @var unknown_type * @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) * 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) { public function isOwnedByOrg($serverid, $org) {
return $this->field('id', array('id' => $serverid, 'org' => $org)) === $serverid; return $this->field('id', array('id' => $serverid, 'org' => $org)) === $serverid;
} }

View File

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

View File

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