-
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.
NEW Allow DataObject classes to define scaffolded relation formfields
- Loading branch information
1 parent
e35f12c
commit cd72258
Showing
9 changed files
with
291 additions
and
55 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace SilverStripe\Forms\Tests\FormScaffolderTest; | ||
|
||
use SilverStripe\Dev\TestOnly; | ||
use SilverStripe\Forms\CurrencyField; | ||
use SilverStripe\Forms\DateField; | ||
use SilverStripe\Forms\FormField; | ||
use SilverStripe\Forms\TimeField; | ||
use SilverStripe\ORM\DataObject; | ||
|
||
class Child extends DataObject implements TestOnly | ||
{ | ||
private static $table_name = 'FormScaffolderTest_Child'; | ||
|
||
private static $db = [ | ||
'Title' => 'Varchar', | ||
]; | ||
|
||
private static $has_one = [ | ||
'Parent' => ParentModel::class, | ||
]; | ||
|
||
public static bool $includeInOwnTab = true; | ||
|
||
public function scaffoldFormFieldForHasOne( | ||
string $fieldName, | ||
?string $fieldTitle, | ||
string $relationName, | ||
DataObject $ownerRecord | ||
): FormField { | ||
// Intentionally return a field that is unlikely to be used by default in the future. | ||
return DateField::create($fieldName, $fieldTitle); | ||
} | ||
|
||
public function scaffoldFormFieldForHasMany( | ||
string $relationName, | ||
?string $fieldTitle, | ||
DataObject $ownerRecord, | ||
bool &$includeInOwnTab | ||
): FormField { | ||
$includeInOwnTab = static::$includeInOwnTab; | ||
// Intentionally return a field that is unlikely to be used by default in the future. | ||
return CurrencyField::create($relationName, $fieldTitle); | ||
} | ||
|
||
public function scaffoldFormFieldForManyMany( | ||
string $relationName, | ||
?string $fieldTitle, | ||
DataObject $ownerRecord, | ||
bool &$includeInOwnTab | ||
): FormField { | ||
$includeInOwnTab = static::$includeInOwnTab; | ||
// Intentionally return a field that is unlikely to be used by default in the future. | ||
return TimeField::create($relationName, $fieldTitle); | ||
} | ||
} |
Oops, something went wrong.