mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #4779 from kinglozzer/pulls/fieldgroup-composite-validation
FIX: Hidden errors for composite fields nested inside FieldGroups (fixes #4773)
This commit is contained in:
commit
83ede291bd
@ -118,7 +118,8 @@ class FieldGroup extends CompositeField {
|
||||
* @return string
|
||||
*/
|
||||
public function Message() {
|
||||
$fs = $this->FieldList();
|
||||
$fs = array();
|
||||
$this->collateDataFields($fs);
|
||||
|
||||
foreach($fs as $subfield) {
|
||||
if($m = $subfield->Message()) $message[] = rtrim($m, ".");
|
||||
@ -131,7 +132,8 @@ class FieldGroup extends CompositeField {
|
||||
* @return string
|
||||
*/
|
||||
public function MessageType() {
|
||||
$fs = $this->FieldList();
|
||||
$fs = array();
|
||||
$this->collateDataFields($fs);
|
||||
|
||||
foreach($fs as $subfield) {
|
||||
if($m = $subfield->MessageType()) $MessageType[] = $m;
|
||||
|
20
tests/forms/FieldGroupTest.php
Normal file
20
tests/forms/FieldGroupTest.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
class FieldGroupTest extends SapphireTest {
|
||||
|
||||
public function testMessagesInsideNestedCompositeFields() {
|
||||
$fieldGroup = new FieldGroup(
|
||||
new CompositeField(
|
||||
$textField = new TextField('TestField', 'Test Field'),
|
||||
$emailField = new EmailField('TestEmailField', 'Test Email Field')
|
||||
)
|
||||
);
|
||||
|
||||
$textField->setError('Test error message', 'warning');
|
||||
$emailField->setError('Test error message', 'error');
|
||||
|
||||
$this->assertEquals('Test error message, Test error message.', $fieldGroup->Message());
|
||||
$this->assertEquals('warning. error', $fieldGroup->MessageType());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user