mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT Allow usage of custom 'fieldClasses' argument to FormScaffolder for relationships
This commit is contained in:
parent
7d01b4042f
commit
654173e46b
@ -96,7 +96,13 @@ class FormScaffolder extends Object {
|
|||||||
if($this->obj->has_one()) {
|
if($this->obj->has_one()) {
|
||||||
foreach($this->obj->has_one() as $relationship => $component) {
|
foreach($this->obj->has_one() as $relationship => $component) {
|
||||||
if($this->restrictFields && !in_array($relationship, $this->restrictFields)) continue;
|
if($this->restrictFields && !in_array($relationship, $this->restrictFields)) continue;
|
||||||
$hasOneField = $this->obj->dbObject("{$relationship}ID")->scaffoldFormField(null, $this->getParamsArray());
|
$fieldName = "{$relationship}ID";
|
||||||
|
if($this->fieldClasses && isset($this->fieldClasses[$fieldName])) {
|
||||||
|
$fieldClass = $this->fieldClasses[$fieldName];
|
||||||
|
$hasOneField = new $fieldClass($fieldName);
|
||||||
|
} else {
|
||||||
|
$hasOneField = $this->obj->dbObject($fieldName)->scaffoldFormField(null, $this->getParamsArray());
|
||||||
|
}
|
||||||
$hasOneField->setTitle($this->obj->fieldLabel($relationship));
|
$hasOneField->setTitle($this->obj->fieldLabel($relationship));
|
||||||
if($this->tabbed) {
|
if($this->tabbed) {
|
||||||
$fields->addFieldToTab("Root.Main", $hasOneField);
|
$fields->addFieldToTab("Root.Main", $hasOneField);
|
||||||
@ -119,7 +125,8 @@ class FormScaffolder extends Object {
|
|||||||
}
|
}
|
||||||
$relationshipFields = singleton($component)->summaryFields();
|
$relationshipFields = singleton($component)->summaryFields();
|
||||||
$foreignKey = $this->obj->getRemoteJoinField($relationship);
|
$foreignKey = $this->obj->getRemoteJoinField($relationship);
|
||||||
$ctf = new ComplexTableField(
|
$fieldClass = (isset($this->fieldClasses[$relationship])) ? $this->fieldClasses[$relationship] : 'ComplexTableField';
|
||||||
|
$ctf = new $fieldClass(
|
||||||
$this,
|
$this,
|
||||||
$relationship,
|
$relationship,
|
||||||
$component,
|
$component,
|
||||||
@ -148,7 +155,8 @@ class FormScaffolder extends Object {
|
|||||||
$relationshipFields = singleton($component)->summaryFields();
|
$relationshipFields = singleton($component)->summaryFields();
|
||||||
$filterWhere = $this->obj->getManyManyFilter($relationship, $component);
|
$filterWhere = $this->obj->getManyManyFilter($relationship, $component);
|
||||||
$filterJoin = $this->obj->getManyManyJoin($relationship, $component);
|
$filterJoin = $this->obj->getManyManyJoin($relationship, $component);
|
||||||
$ctf = new ComplexTableField(
|
$fieldClass = (isset($this->fieldClasses[$relationship])) ? $this->fieldClasses[$relationship] : 'ComplexTableField';
|
||||||
|
$ctf = new $fieldClass(
|
||||||
$this,
|
$this,
|
||||||
$relationship,
|
$relationship,
|
||||||
$component,
|
$component,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user