Browse files

ENHANCEMENT Allow usage of custom 'fieldClasses' argument to FormScaf…

…folder for relationships
  • Loading branch information...
1 parent 7d01b40 commit 654173e46b5c6bba464d6bc10da9d27757e6ef95 @chillu chillu committed Aug 22, 2011
Showing with 11 additions and 3 deletions.
  1. +11 −3 forms/FormScaffolder.php
View
14 forms/FormScaffolder.php
@@ -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);
@@ -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,
@@ -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,

0 comments on commit 654173e

Please sign in to comment.