Skip to content

Commit 04d259d

Browse files
committed
widgets form validation bug fixed
1 parent 7abd109 commit 04d259d

File tree

7 files changed

+51
-37
lines changed

7 files changed

+51
-37
lines changed

Ajax/common/Widget.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,16 @@ abstract class Widget extends HtmlDoubleElement {
4848
*/
4949
protected $_form;
5050

51+
protected $_generated;
52+
5153

5254
public function __construct($identifier,$model,$modelInstance=NULL) {
5355
parent::__construct($identifier);
5456
$this->_template="%wrapContentBefore%%content%%wrapContentAfter%";
5557
$this->setModel($model);
5658
if(isset($modelInstance));
5759
$this->show($modelInstance);
60+
$this->_generated=false;
5861
}
5962

6063
protected function _init($instanceViewer,$contentKey,$content,$edition){
@@ -336,7 +339,7 @@ public function getForm() {
336339
public function run(JsUtils $js){
337340
$result=parent::run($js);
338341
if(isset($this->_form)){
339-
$this->runForm($js);
342+
$result=$this->runForm($js);
340343
}
341344
return $result;
342345
}

Ajax/common/html/BaseHtml.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ protected function ctrl($name, $value, $typeCtrl) {
110110
return true;
111111
}
112112

113-
protected function propertyContains($propertyName, $value) {
113+
public function propertyContains($propertyName, $value) {
114114
$values=$this->getProperty($propertyName);
115115
if (isset($values)) {
116116
return JString::contains($values, $value);

Ajax/semantic/html/collections/form/HtmlForm.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,9 @@ public function getValidationParams() {
190190
return $this->_validationParams;
191191
}
192192

193+
public function removeValidationParam($param){
194+
unset($this->_validationParams[$param]);
195+
return $this;
196+
}
197+
193198
}

Ajax/semantic/html/collections/form/traits/FormTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ protected function _runValidationParams(&$compo,JsUtils $js=NULL){
2929
$compilation=$params["_ajaxSubmit"]->compile($js);
3030
$compilation=str_ireplace("\"","%quote%", $compilation);
3131
$this->onSuccess($compilation);
32-
unset($params["_ajaxSubmit"]);
32+
$form->removeValidationParam("_ajaxSubmit");
3333
}
34-
$compo->addParams($params);
34+
$compo->addParams($form->getValidationParams());
3535
$form->setBsComponent($compo);
3636
$form->addEventsOnRun($js);
3737
}

Ajax/semantic/widgets/base/FieldAsTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,6 @@ public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=N
238238
$button=new HtmlButton($id,$value,$cssStyle);
239239
$this->_buttonAsSubmit($button,"click",$url,$responseElement);
240240
return $button;
241-
}, $index,$attributes);
241+
}, $index,$attributes,"submit");
242242
}
243243
}

Ajax/semantic/widgets/dataelement/DataElement.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,19 @@ public function __construct($identifier, $modelInstance=NULL) {
2525
}
2626

2727
public function compile(JsUtils $js=NULL,&$view=NULL){
28-
$this->_instanceViewer->setInstance($this->_modelInstance);
28+
if(!$this->_generated){
29+
$this->_instanceViewer->setInstance($this->_modelInstance);
2930

30-
$table=$this->content["table"];
31-
$this->_generateContent($table);
31+
$table=$this->content["table"];
32+
$this->_generateContent($table);
3233

33-
if(isset($this->_toolbar)){
34-
$this->_setToolbarPosition($table);
34+
if(isset($this->_toolbar)){
35+
$this->_setToolbarPosition($table);
36+
}
37+
$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
38+
$this->_compileForm();
39+
$this->_generated=true;
3540
}
36-
$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
37-
$this->_compileForm();
3841
return parent::compile($js,$view);
3942
}
4043

Ajax/semantic/widgets/datatable/DataTable.php

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -60,37 +60,40 @@ protected function getTable() {
6060

6161

6262
public function compile(JsUtils $js=NULL,&$view=NULL){
63-
$this->_instanceViewer->setInstance($this->_model);
64-
$captions=$this->_instanceViewer->getCaptions();
63+
if(!$this->_generated){
64+
$this->_instanceViewer->setInstance($this->_model);
65+
$captions=$this->_instanceViewer->getCaptions();
6566

66-
$table=$this->content["table"];
67+
$table=$this->content["table"];
6768

68-
if($this->_hasCheckboxes){
69-
$this->_generateMainCheckbox($captions);
70-
}
69+
if($this->_hasCheckboxes){
70+
$this->_generateMainCheckbox($captions);
71+
}
7172

72-
$table->setRowCount(0, \sizeof($captions));
73-
$table->setHeaderValues($captions);
74-
if(isset($this->_compileParts))
75-
$table->setCompileParts($this->_compileParts);
76-
if(isset($this->_searchField) && isset($js)){
77-
$this->_searchField->postOn("change", $this->_urls,"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
78-
}
73+
$table->setRowCount(0, \sizeof($captions));
74+
$table->setHeaderValues($captions);
75+
if(isset($this->_compileParts))
76+
$table->setCompileParts($this->_compileParts);
77+
if(isset($this->_searchField) && isset($js)){
78+
$this->_searchField->postOn("change", $this->_urls,"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
79+
}
7980

80-
$this->_generateContent($table);
81+
$this->_generateContent($table);
8182

82-
if($this->_hasCheckboxes && $table->hasPart("thead")){
83-
$table->getHeader()->getCell(0, 0)->addToProperty("class","no-sort");
84-
}
83+
if($this->_hasCheckboxes && $table->hasPart("thead")){
84+
$table->getHeader()->getCell(0, 0)->addToProperty("class","no-sort");
85+
}
8586

86-
if(isset($this->_pagination) && $this->_pagination->getVisible()){
87-
$this->_generatePagination($table);
88-
}
89-
if(isset($this->_toolbar)){
90-
$this->_setToolbarPosition($table, $captions);
87+
if(isset($this->_pagination) && $this->_pagination->getVisible()){
88+
$this->_generatePagination($table);
89+
}
90+
if(isset($this->_toolbar)){
91+
$this->_setToolbarPosition($table, $captions);
92+
}
93+
$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
94+
$this->_compileForm();
95+
$this->_generated=true;
9196
}
92-
$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
93-
$this->_compileForm();
9497
return parent::compile($js,$view);
9598
}
9699

@@ -296,7 +299,7 @@ public function insertInFieldButton($index,$caption,$visibleHover=true,$callback
296299
}
297300

298301
private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){
299-
$this->addField($this->getCallable("getDefaultButton",[$icon,$class],$visibleHover,$callback));
302+
$this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback));
300303
return $this;
301304
}
302305

0 commit comments

Comments
 (0)