1 <?php
2 /**
3 * IdentificationColumnValidator class file.
4 *
5 * @author Herbert Maschke <thyseus@gmail.com>
6 * This file is part of the gii-template-collection
7 */
8
9 /**
10 * IdentificationColumnValidator is automatically applied by FullModel
11 * to any column that 'identifies' the Model in a human-readable way. There
12 * are certain rules that need to be applied, since the column can appear
13 * in the URL. There should not be a / inside it and there should not be a .
14 * (dot) as last character.
15 *
16 * Child classes must implement the {@link validateAttribute} method.
17 *
18 */
19 class IdentificationColumnValidator extends CValidator
20 {
21 protected function validateAttribute($object,$attribute) {
22 if(isset($object->$attribute)) {
23 if($object->$attribute) {
24 if(substr($object->$attribute, 0, -1) == '.')
25 $object->addError($attribute, Yii::t('app',
26 'Please do not use a . (dot) as the last character for this column'));
27
28 if(strpos($object->$attribute, '/') !== false)
29 $object->addError($attribute, Yii::t('app',
30 'Please do not use a / (slash) for this column'));
31 }
32 }
33 }
34
35 public function clientValidateAttribute($object,$attribute)
36 {
37 }
38
39 }
40
41