1 : <?php
2 :
3 :
4 :
5 :
6 :
7 :
8 :
9 :
10 :
11 :
12 :
13 :
14 :
15 : class BasicForm extends CFormModel {
16 : public $attribute_boolean;
17 : public $attribute_number;
18 : public $attribute_range;
19 : public $attribute_regex;
20 : public $attribute_string;
21 : public $attribute_safe;
22 :
23 : public function rules() {
24 : return array (
25 :
26 :
27 :
28 :
29 :
30 :
31 :
32 :
33 :
34 : array (
35 3 : 'attribute_number, attribute_range, attribute_regex, attribute_string',
36 3 : 'required',
37 3 : 'on' => 'scenario_default',
38 3 : ),
39 :
40 : array (
41 3 : 'attribute_boolean',
42 3 : 'boolean',
43 3 : 'on' => 'scenario_default',
44 3 : ),
45 :
46 : array (
47 3 : 'attribute_number',
48 3 : 'numerical',
49 3 : 'min' => 1,
50 3 : 'max' => 10,
51 3 : 'on' => 'scenario_default',
52 3 : ),
53 :
54 : array (
55 3 : 'attribute_range',
56 3 : 'in',
57 3 : 'range' => array (1,3,5,7,9),
58 3 : 'on' => 'scenario_default',
59 3 : ),
60 :
61 : array (
62 3 : 'attribute_regex',
63 3 : 'match',
64 3 : 'pattern' => '/\w+ \d+/',
65 3 : 'message' => '{attribute} must contain a word, a space then a number.',
66 3 : 'on' => 'scenario_default',
67 3 : ),
68 :
69 : array (
70 3 : 'attribute_string',
71 3 : 'length',
72 3 : 'max' => 15,
73 3 : 'on' => 'scenario_default',
74 3 : ),
75 : array (
76 3 : 'attribute_safe',
77 3 : 'safe',
78 3 : 'on' => 'scenario_default',
79 3 : ),
80 3 : );
81 : }
82 :
83 : public function attributeLabels () {
84 : return array (
85 2 : 'attribute_boolean' => 'Boolean (True or False)',
86 2 : 'attribute_number' => 'Number (1 to 10)',
87 2 : 'attribute_range' => 'Range (1,3,5,7,9)',
88 2 : 'attribute_regex' => 'Regular expression (word space number)',
89 2 : 'attribute_string' => 'String (only 15 characters)',
90 2 : 'attribute_safe' => 'Safe (anything can go here or nothing can)',
91 2 : );
92 : }
93 :
94 : }
|