BUG Fix buttonClicked() error

Fixes #3208
This commit is contained in:
Damian Mooyman 2016-06-08 12:10:01 +12:00
parent 39d1ef7a4b
commit bf00810e1f
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A
2 changed files with 18 additions and 6 deletions

View File

@ -1635,11 +1635,17 @@ class Form extends RequestHandler {
* @return FormAction
*/
public function buttonClicked() {
foreach($this->actions->dataFields() as $action) {
if($action->hasMethod('actionname') && $this->buttonClickedFunc == $action->actionName()) {
$actions = $this->actions->dataFields();
if(!$actions) {
return null;
}
foreach($actions as $action) {
if($action instanceof FormAction && $this->buttonClickedFunc == $action->actionName()) {
return $action;
}
}
return null;
}
/**

View File

@ -537,6 +537,12 @@ class FormTest extends FunctionalTest {
$this->assertEquals('bar', $attrs['foo']);
}
public function testButtonClicked() {
$form = $this->getStubForm();
$action = $form->buttonClicked();
$this->assertNull($action);
}
public function testAttributesHTML() {
$form = $this->getStubForm();