-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX Add polymorphic class on new records for use in forms.
- Loading branch information
1 parent
2836478
commit faacbd9
Showing
5 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
tests/php/Forms/GridField/GridFieldDetailFormTest/PolymorphicPeopleGroup.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace SilverStripe\Forms\Tests\GridField\GridFieldDetailFormTest; | ||
|
||
use SilverStripe\Dev\TestOnly; | ||
use SilverStripe\Forms\GridField\GridField; | ||
use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor; | ||
use SilverStripe\ORM\DataObject; | ||
|
||
class PeopleGroup extends DataObject implements TestOnly | ||
{ | ||
private static $table_name = 'GridFieldDetailFormTest_PolymorphicPeopleGroup'; | ||
|
||
private static $db = [ | ||
'Name' => 'Varchar' | ||
]; | ||
|
||
private static $has_many = [ | ||
'People' => Person::class | ||
]; | ||
|
||
private static $default_sort = '"Name"'; | ||
|
||
public function getCMSFields() | ||
{ | ||
$fields = parent::getCMSFields(); | ||
$fields->replaceField( | ||
'People', | ||
GridField::create( | ||
'People', | ||
'People', | ||
$this->People(), | ||
GridFieldConfig_RelationEditor::create() | ||
) | ||
); | ||
return $fields; | ||
} | ||
} |