mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '4.10' into 4
This commit is contained in:
commit
511b8a4c71
@ -1355,13 +1355,14 @@ class FormField extends RequestHandler
|
|||||||
$field = $classOrCopy::create($this->name);
|
$field = $classOrCopy::create($this->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$extraClasses = $this->extraClasses ? array_values($this->extraClasses) : [];
|
||||||
$field
|
$field
|
||||||
->setValue($this->value)
|
->setValue($this->value)
|
||||||
->setForm($this->form)
|
->setForm($this->form)
|
||||||
->setTitle($this->Title())
|
->setTitle($this->Title())
|
||||||
->setLeftTitle($this->LeftTitle())
|
->setLeftTitle($this->LeftTitle())
|
||||||
->setRightTitle($this->RightTitle())
|
->setRightTitle($this->RightTitle())
|
||||||
->addExtraClass($this->extraClass) // Don't use extraClass(), since this merges calculated values
|
->addExtraClass(implode(' ', $extraClasses)) // Don't use extraClass(), since this merges calculated values
|
||||||
->setDescription($this->getDescription());
|
->setDescription($this->getDescription());
|
||||||
|
|
||||||
// Only include built-in attributes, ignore anything set through getAttributes().
|
// Only include built-in attributes, ignore anything set through getAttributes().
|
||||||
|
@ -937,6 +937,11 @@ class Member extends DataObject
|
|||||||
$this->Locale = i18n::config()->get('default_locale');
|
$this->Locale = i18n::config()->get('default_locale');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure FailedLoginCount is non-negative
|
||||||
|
if ($this->FailedLoginCount < 0) {
|
||||||
|
$this->FailedLoginCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
parent::onBeforeWrite();
|
parent::onBeforeWrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,6 +259,14 @@ class FormFieldTest extends SapphireTest
|
|||||||
$this->assertStringNotContainsString('readonly="readonly"', $field->getAttributesHTML());
|
$this->assertStringNotContainsString('readonly="readonly"', $field->getAttributesHTML());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testReadonlyPreservesExtraClass()
|
||||||
|
{
|
||||||
|
$field = new FormField('MyField');
|
||||||
|
$field->addExtraClass('myextraclass1')->addExtraClass('myextraclass2');
|
||||||
|
$field->setReadonly(true);
|
||||||
|
$this->assertStringContainsString('myextraclass1 myextraclass2', $field->getAttributesHTML());
|
||||||
|
}
|
||||||
|
|
||||||
public function testDisabled()
|
public function testDisabled()
|
||||||
{
|
{
|
||||||
$field = new FormField('MyField');
|
$field = new FormField('MyField');
|
||||||
|
@ -203,7 +203,7 @@ class TreeMultiselectFieldTest extends SapphireTest
|
|||||||
$this->assertSame('TreeDropdownField', $schemaDataDefaults['component']);
|
$this->assertSame('TreeDropdownField', $schemaDataDefaults['component']);
|
||||||
$this->assertSame(sprintf('%s_Holder', $field->ID()), $schemaDataDefaults['holderId']);
|
$this->assertSame(sprintf('%s_Holder', $field->ID()), $schemaDataDefaults['holderId']);
|
||||||
$this->assertSame('Test tree', $schemaDataDefaults['title']);
|
$this->assertSame('Test tree', $schemaDataDefaults['title']);
|
||||||
$this->assertSame('treemultiselectfield_readonly multiple searchable', $schemaDataDefaults['extraClass']);
|
$this->assertSame('treemultiselectfield_readonly multiple searchable', $schemaDataDefaults['extraClass']);
|
||||||
$this->assertSame('field/TestTree/tree', $schemaDataDefaults['data']['urlTree']);
|
$this->assertSame('field/TestTree/tree', $schemaDataDefaults['data']['urlTree']);
|
||||||
$this->assertSame(true, $schemaDataDefaults['data']['showSearch']);
|
$this->assertSame(true, $schemaDataDefaults['data']['showSearch']);
|
||||||
$this->assertSame('(Search or choose File)', $schemaDataDefaults['data']['emptyString']);
|
$this->assertSame('(Search or choose File)', $schemaDataDefaults['data']['emptyString']);
|
||||||
@ -239,7 +239,7 @@ class TreeMultiselectFieldTest extends SapphireTest
|
|||||||
$this->assertSame('TreeDropdownField', $schemaDataDefaults['component']);
|
$this->assertSame('TreeDropdownField', $schemaDataDefaults['component']);
|
||||||
$this->assertSame(sprintf('%s_Holder', $field->ID()), $schemaDataDefaults['holderId']);
|
$this->assertSame(sprintf('%s_Holder', $field->ID()), $schemaDataDefaults['holderId']);
|
||||||
$this->assertSame('Test tree', $schemaDataDefaults['title']);
|
$this->assertSame('Test tree', $schemaDataDefaults['title']);
|
||||||
$this->assertSame('treemultiselectfield_readonly multiple searchable', $schemaDataDefaults['extraClass']);
|
$this->assertSame('treemultiselectfield_readonly multiple searchable', $schemaDataDefaults['extraClass']);
|
||||||
$this->assertSame('field/TestTree/tree', $schemaDataDefaults['data']['urlTree']);
|
$this->assertSame('field/TestTree/tree', $schemaDataDefaults['data']['urlTree']);
|
||||||
$this->assertSame(true, $schemaDataDefaults['data']['showSearch']);
|
$this->assertSame(true, $schemaDataDefaults['data']['showSearch']);
|
||||||
$this->assertSame('(Search or choose File)', $schemaDataDefaults['data']['emptyString']);
|
$this->assertSame('(Search or choose File)', $schemaDataDefaults['data']['emptyString']);
|
||||||
|
@ -1270,6 +1270,15 @@ class MemberTest extends FunctionalTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFailedLoginCountNegative()
|
||||||
|
{
|
||||||
|
/** @var Member $member */
|
||||||
|
$member = $this->objFromFixture(Member::class, 'test');
|
||||||
|
$member->FailedLoginCount = -1;
|
||||||
|
$member->write();
|
||||||
|
$this->assertSame(0, $member->FailedLoginCount);
|
||||||
|
}
|
||||||
|
|
||||||
public function testMemberValidator()
|
public function testMemberValidator()
|
||||||
{
|
{
|
||||||
// clear custom requirements for this test
|
// clear custom requirements for this test
|
||||||
|
Loading…
Reference in New Issue
Block a user