ENHANCEMENT Allow usage of custom 'fieldClasses' argument to FormScaffolder for relationships

This commit is contained in:
Ingo Schommer 2011-08-22 08:55:49 +02:00
parent 7d01b4042f
commit 654173e46b

View File

@ -96,7 +96,13 @@ class FormScaffolder extends Object {
if($this->obj->has_one()) {
foreach($this->obj->has_one() as $relationship => $component) {
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));
if($this->tabbed) {
$fields->addFieldToTab("Root.Main", $hasOneField);
@ -119,7 +125,8 @@ class FormScaffolder extends Object {
}
$relationshipFields = singleton($component)->summaryFields();
$foreignKey = $this->obj->getRemoteJoinField($relationship);
$ctf = new ComplexTableField(
$fieldClass = (isset($this->fieldClasses[$relationship])) ? $this->fieldClasses[$relationship] : 'ComplexTableField';
$ctf = new $fieldClass(
$this,
$relationship,
$component,
@ -148,7 +155,8 @@ class FormScaffolder extends Object {
$relationshipFields = singleton($component)->summaryFields();
$filterWhere = $this->obj->getManyManyFilter($relationship, $component);
$filterJoin = $this->obj->getManyManyJoin($relationship, $component);
$ctf = new ComplexTableField(
$fieldClass = (isset($this->fieldClasses[$relationship])) ? $this->fieldClasses[$relationship] : 'ComplexTableField';
$ctf = new $fieldClass(
$this,
$relationship,
$component,