Skip to content

Commit a2ea10a

Browse files
committed
[Fix] _getIndex method can return false if field is not found
1 parent dfdbfa8 commit a2ea10a

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Ajax/common/Widget.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ public function setAttached($value=true){
141141
*/
142142
public function afterCompile($index,$callback){
143143
$index=$this->_getIndex($index);
144-
$this->_instanceViewer->afterCompile($index, $callback);
144+
if($index!==false){
145+
$this->_instanceViewer->afterCompile($index, $callback);
146+
}
145147
return $this;
146148
}
147149

@@ -198,7 +200,9 @@ public function insertField($index,$field,$key=null){
198200

199201
public function insertInField($index,$field,$key=null){
200202
$index=$this->_getIndex($index);
201-
$this->_instanceViewer->insertInField($index, $field,$key);
203+
if($index!==false){
204+
$this->_instanceViewer->insertInField($index, $field,$key);
205+
}
202206
return $this;
203207
}
204208

@@ -210,7 +214,9 @@ public function insertInField($index,$field,$key=null){
210214
*/
211215
public function setValueFunction($index,$callback){
212216
$index=$this->_getIndex($index);
213-
$this->_instanceViewer->setValueFunction($index, $callback);
217+
if($index!==false){
218+
$this->_instanceViewer->setValueFunction($index, $callback);
219+
}
214220
return $this;
215221
}
216222

@@ -460,7 +466,9 @@ public function swapFields($index1,$index2){
460466

461467
public function removeField($index){
462468
$index=$this->_getIndex($index);
463-
$this->_instanceViewer->removeField($index);
469+
if($index!==false){
470+
$this->_instanceViewer->removeField($index);
471+
}
464472
return $this;
465473
}
466474

0 commit comments

Comments
 (0)