mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUG FormField->removeExtraClass() works on indexed arrays
Was assuming an associative map, which isn't the case in the current implementations.
This commit is contained in:
parent
d342794cfe
commit
2d04de0377
@ -321,9 +321,9 @@ class FormField extends RequestHandler {
|
|||||||
* @param $class String
|
* @param $class String
|
||||||
*/
|
*/
|
||||||
public function removeExtraClass($class) {
|
public function removeExtraClass($class) {
|
||||||
if(isset($this->extraClasses) && array_key_exists($class, $this->extraClasses)) {
|
$pos = array_search($class, $this->extraClasses);
|
||||||
unset($this->extraClasses[$class]);
|
if($pos !== false) unset($this->extraClasses[$pos]);
|
||||||
}
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,22 @@
|
|||||||
*/
|
*/
|
||||||
class FormFieldTest extends SapphireTest {
|
class FormFieldTest extends SapphireTest {
|
||||||
|
|
||||||
|
public function testAddExtraClass() {
|
||||||
|
$field = new FormField('MyField');
|
||||||
|
$field->addExtraClass('class1');
|
||||||
|
$field->addExtraClass('class2');
|
||||||
|
$this->assertStringEndsWith('class1 class2', $field->extraClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRemoveExtraClass() {
|
||||||
|
$field = new FormField('MyField');
|
||||||
|
$field->addExtraClass('class1');
|
||||||
|
$field->addExtraClass('class2');
|
||||||
|
$this->assertStringEndsWith('class1 class2', $field->extraClass());
|
||||||
|
$field->removeExtraClass('class1');
|
||||||
|
$this->assertStringEndsWith('class2', $field->extraClass());
|
||||||
|
}
|
||||||
|
|
||||||
public function testAttributes() {
|
public function testAttributes() {
|
||||||
$field = new FormField('MyField');
|
$field = new FormField('MyField');
|
||||||
$field->setAttribute('foo', 'bar');
|
$field->setAttribute('foo', 'bar');
|
||||||
|
Loading…
Reference in New Issue
Block a user