diff --git a/src/Common/PrefixSubmitButton.php b/src/Common/PrefixSubmitButton.php new file mode 100644 index 00000000..3c156cbc --- /dev/null +++ b/src/Common/PrefixSubmitButton.php @@ -0,0 +1,23 @@ +getAttributes(); + $attr->setAttribute( + Attribute::create('class', 'hidePrefixElement') + ); + + $submit = new SubmitElement($originalSubmitButton->getName(), $attr); + $submit->setValue($originalSubmitButton->getValue()); + + return $submit; + } +} diff --git a/tests/common/PrefixSubmitButtonTest.php b/tests/common/PrefixSubmitButtonTest.php new file mode 100644 index 00000000..1707c58b --- /dev/null +++ b/tests/common/PrefixSubmitButtonTest.php @@ -0,0 +1,27 @@ + 'autosubmit' + ]); + + $prefixButton = $this->createSubmitButton($submitButton); + + // Name should stay the same + $this->assertSame($submitButton->getName(), 'test_submit'); + $this->assertSame($prefixButton->getName(), 'test_submit'); + + // Class Attribute should change to `hideElement` + $this->assertSame($submitButton->getAttributes()->get('class')->getValue(), 'autosubmit'); + $this->assertSame($prefixButton->getAttributes()->get('class')->getValue(), 'hideElement'); + } +}