1: <?php
2: 3: 4: 5: 6: 7: 8:
9:
10: Yii::import('gii.generators.crud.CrudCode');
11:
12: class BootstrapCode extends CrudCode
13: {
14: public function generateControlGroup($modelClass, $column)
15: {
16: if ($column->type === 'boolean') {
17: return "TbHtml::activeCheckBoxControlGroup(\$model,'{$column->name}')";
18: } else {
19: if (stripos($column->dbType, 'text') !== false) {
20: return "TbHtml::activeTextAreaControlGroup(\$model,'{$column->name}',array('rows'=>6,'span'=>8))";
21: } else {
22: if (preg_match('/^(password|pass|passwd|passcode)$/i', $column->name)) {
23: $inputField = 'activePasswordControlGroup';
24: } else {
25: $inputField = 'activeTextFieldControlGroup';
26: }
27:
28: if ($column->type !== 'string' || $column->size === null) {
29: return "TbHtml::{$inputField}(\$model,'{$column->name}')";
30: } else {
31: if (($size = $maxLength = $column->size) > 60) {
32: $size = 60;
33: }
34: return "TbHtml::{$inputField}(\$model,'{$column->name}',array('size'=>$size,'maxlength'=>$maxLength))";
35: }
36: }
37: }
38: }
39:
40: public function generateActiveControlGroup($modelClass, $column)
41: {
42: if ($column->type === 'boolean') {
43: return "\$form->checkBoxControlGroup(\$model,'{$column->name}')";
44: } else {
45: if (stripos($column->dbType, 'text') !== false) {
46: return "\$form->textAreaControlGroup(\$model,'{$column->name}',array('rows'=>6,'span'=>8))";
47: } else {
48: if (preg_match('/^(password|pass|passwd|passcode)$/i', $column->name)) {
49: $inputField = 'passwordFieldControlGroup';
50: } else {
51: $inputField = 'textFieldControlGroup';
52: }
53:
54: if ($column->type !== 'string' || $column->size === null) {
55: return "\$form->{$inputField}(\$model,'{$column->name}',array('span'=>5))";
56: } else {
57: return "\$form->{$inputField}(\$model,'{$column->name}',array('span'=>5,'maxlength'=>$column->size))";
58: }
59: }
60: }
61: }
62: }
63: