1 <?php
2 /**
3 * CActiveForm class file.
4 */
5
6 class UActiveForm extends CActiveForm
7 {
8
9 public $disableAjaxValidationAttributes = array();
10
11 public function run()
12 {
13 if(is_array($this->focus))
14 $this->focus="#".CHtml::activeId($this->focus[0],$this->focus[1]);
15
16 echo CHtml::endForm();
17 $cs=Yii::app()->clientScript;
18 if(!$this->enableAjaxValidation && !$this->enableClientValidation || empty($this->attributes))
19 {
20 if($this->focus!==null)
21 {
22 $cs->registerCoreScript('jquery');
23 $cs->registerScript('CActiveForm#focus',"
24 if(!window.location.hash)
25 $('".$this->focus."').focus();
26 ");
27 }
28 return;
29 }
30
31 $options=$this->clientOptions;
32 if(isset($this->clientOptions['validationUrl']) && is_array($this->clientOptions['validationUrl']))
33 $options['validationUrl']=CHtml::normalizeUrl($this->clientOptions['validationUrl']);
34
35 $options['attributes']=array();
36 foreach ($this->attributes as $attr => $item) {
37 if (in_array($attr,$this->disableAjaxValidationAttributes)===false) {
38 array_push($options['attributes'],$item);
39 }
40 }
41
42 if($this->summaryID!==null)
43 $options['summaryID']=$this->summaryID;
44
45 if($this->focus!==null)
46 $options['focus']=$this->focus;
47
48 $options=CJavaScript::encode($options);
49 $cs->registerCoreScript('yiiactiveform');
50 $id=$this->id;
51 $cs->registerScript(__CLASS__.'#'.$id,"\$('#$id').yiiactiveform($options);");
52
53 /*
54 parent::run();
55 $cs = Yii::app()->getClientScript();
56 $js = "// UActiveForm\n$('".'#'.implode(', #',$this->disableAjaxValidationAttributes)."').die('focusout','');";
57 //echo '<pre>'; print_r(); die();
58 $cs->registerScript(__CLASS__.'#dialog', $js);
59
60 if(is_array($this->focus))
61 $this->focus="#".CHtml::activeId($this->focus[0],$this->focus[1]);
62
63 echo CHtml::endForm();
64 $cs=Yii::app()->clientScript;
65 if(!$this->enableAjaxValidation && !$this->enableClientValidation || empty($this->attributes))
66 {
67 if($this->focus!==null)
68 {
69 $cs->registerCoreScript('jquery');
70 $cs->registerScript('CActiveForm#focus',"
71 if(!window.location.hash)
72 $('".$this->focus."').focus();
73 ");
74 }
75 return;
76 }
77
78 $options=$this->clientOptions;
79 if(isset($this->clientOptions['validationUrl']) && is_array($this->clientOptions['validationUrl']))
80 $options['validationUrl']=CHtml::normalizeUrl($this->clientOptions['validationUrl']);
81
82 $options['attributes']=array();
83 foreach ($this->attributes as $attr => $item) {
84 if (in_array($attr,$this->disableAjaxValidationAttributes)===false) {
85 array_push($options['attributes'],$item);
86 }
87 }
88
89 if($this->summaryID!==null)
90 $options['summaryID']=$this->summaryID;
91
92 if($this->focus!==null)
93 $options['focus']=$this->focus;
94
95 $options=CJavaScript::encode($options);
96 $cs->registerCoreScript('yiiactiveform');
97 $id=$this->id;
98 $cs->registerScript(__CLASS__.'#'.$id,"\$('#$id').yiiactiveform($options);");
99 //*/
100 }
101 }
102
103