ENHANCEMENT: allowing empty children

ENHANCEMENT: added Fields()
ENHANCEMENT: added linebreaks for html

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@43558 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2007-10-18 01:05:52 +00:00
parent 0a85936f2f
commit 53f75e957d

View File

@ -46,6 +46,10 @@ class CompositeField extends FormField {
$this->id = $id; $this->id = $id;
} }
public function Field() {
return $this->FieldHolder();
}
/** /**
* Returns the fields nested inside another DIV * Returns the fields nested inside another DIV
*/ */
@ -53,18 +57,18 @@ class CompositeField extends FormField {
$fs = $this->FieldSet(); $fs = $this->FieldSet();
$idAtt = isset($this->id) ? " id=\"{$this->id}\"" : ''; $idAtt = isset($this->id) ? " id=\"{$this->id}\"" : '';
$className = ($this->columnCount) ? "field CompositeField {$this->extraClass()} multicolumn" : "field CompositeField {$this->extraClass()}"; $className = ($this->columnCount) ? "field CompositeField {$this->extraClass()} multicolumn" : "field CompositeField {$this->extraClass()}";
$content = "<div class=\"$className\"$idAtt>"; $content = "<div class=\"$className\"$idAtt>\n";
foreach($fs as $subfield) { foreach($fs as $subfield) {
if($this->columnCount) { if($this->columnCount) {
$className = "column{$this->columnCount}"; $className = "column{$this->columnCount}";
if(!next($fs)) $className .= " lastcolumn"; if(!next($fs)) $className .= " lastcolumn";
$content .= "<div class=\"{$className}\">" . $subfield->FieldHolder() . "</div>"; $content .= "\n<div class=\"{$className}\">\n" . $subfield->FieldHolder() . "\n</div>\n";
} else if($subfield){ } else if($subfield){
$content .= $subfield->FieldHolder() . " "; $content .= "\n" . $subfield->FieldHolder() . "\n";
} }
} }
$content .= "</div>"; $content .= "</div>\n";
return $content; return $content;
} }