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
This commit is contained in:
Ingo Schommer 2007-09-16 16:05:05 +00:00
parent a8433baee2
commit 864c0ba021

View File

@ -67,8 +67,30 @@ class CompositeField extends FormField {
$content .= "</div>";
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 = "<div class=\"$className\"$idAtt>";
foreach($fs as $subfield) {//echo ' subf'.$subfield->Name();
if($this->columnCount) {
$className = "column{$this->columnCount}";
if(!next($fs)) $className .= " lastcolumn";
$content .= "<div class=\"{$className}\">" . $subfield->FieldHolder() . "</div>";
} else if($subfield){
$content .= $subfield->SmallFieldHolder() . " ";
}
}
$content .= "</div>";
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);