From 864c0ba021290242b593c2583b35828db43bd7d9 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Sun, 16 Sep 2007 16:05:05 +0000 Subject: [PATCH] bfojcapell: Added function SmallFieldHolder? to properly render fields when this function is called in a FieldGroup?. Also added function insertBeforeRecursive (see www.silverstripe.com/google-summer-of-code-forum/show/3005). This function is only called in Translatable.php at this moment, so if finally insertBefore gets a recursive behaviour then the call can be changed and insertBeforeRecursive deleted. (merged from branches/gsoc) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@42110 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/CompositeField.php | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/forms/CompositeField.php b/forms/CompositeField.php index 0e4eeee51..4f11865e0 100755 --- a/forms/CompositeField.php +++ b/forms/CompositeField.php @@ -67,8 +67,30 @@ class CompositeField extends FormField { $content .= ""; return $content; - } + } + + /** + * Returns the fields in the restricted field holder inside a DIV. + */ + function SmallFieldHolder() {//return $this->FieldHolder(); + $fs = $this->FieldSet(); + $idAtt = isset($this->id) ? " id=\"{$this->id}\"" : ''; + $className = ($this->columnCount) ? "field CompositeField {$this->extraClass()} multicolumn" : "field CompositeField {$this->extraClass()}"; + $content = "
"; + + foreach($fs as $subfield) {//echo ' subf'.$subfield->Name(); + if($this->columnCount) { + $className = "column{$this->columnCount}"; + if(!next($fs)) $className .= " lastcolumn"; + $content .= "
" . $subfield->FieldHolder() . "
"; + } else if($subfield){ + $content .= $subfield->SmallFieldHolder() . " "; + } + } + $content .= "
"; + return $content; + } /** * Add all of the non-composite fields contained within this field to the list. * Sequentialisation is used when connecting the form to its data source @@ -108,7 +130,11 @@ class CompositeField extends FormField { $this->children->push($field); } public function insertBefore($field, $insertBefore) { - $this->children->insertBefore($field, $insertBefore); + return $this->children->insertBefore($field, $insertBefore); + } + + public function insertBeforeRecursive($field, $insertBefore, $level = 0) { + return $this->children->insertBeforeRecursive($field, $insertBefore, $level+1); } public function removeByName($fieldName) { $this->children->removeByName($fieldName);