Skip to content

Commit

Permalink
ENHANCEMENT Allow usage of custom 'fieldClasses' argument to FormScaf…
Browse files Browse the repository at this point in the history
…folder for relationships
  • Loading branch information
chillu committed Aug 22, 2011
1 parent 7d01b40 commit 654173e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions forms/FormScaffolder.php
Expand Up @@ -96,7 +96,13 @@ public function getFieldSet() {
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);
Expand All @@ -119,7 +125,8 @@ public function getFieldSet() {
}
$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,
Expand Down Expand Up @@ -148,7 +155,8 @@ public function getFieldSet() {
$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,
Expand Down

0 comments on commit 654173e

Please sign in to comment.