Merge pull request #3858 from dhensby/pulls/fix-empty-composite-fields

FIX issue where empty composite fields created a fieldlist with empty items
This commit is contained in:
Loz Calver 2015-02-11 17:18:33 +00:00
commit f3c3562fdc
2 changed files with 9 additions and 5 deletions

View File

@ -47,13 +47,14 @@ class CompositeField extends FormField {
if($children instanceof FieldList) {
$this->children = $children;
} elseif(is_array($children)) {
$this->children = new FieldList($children);
$this->children = new FieldList($children);
} else {
$children = is_array(func_get_args()) ? func_get_args() : array();
$this->children = new FieldList($children);
//filter out null/empty items
$children = array_filter(func_get_args());
$this->children = new FieldList($children);
}
$this->children->setContainerField($this);
// Skipping FormField::__construct(), but we have to make sure this
// doesn't count as a broken constructor
$this->brokenOnConstruct = false;

View File

@ -13,7 +13,10 @@
<ul class="SelectionGroup<% if extraClass %> $extraClass<% end_if %>">
<% loop $FieldSet %>
<li$Selected>
{$RadioButton}{$RadioLabel}{$FieldHolder}
{$RadioButton}{$RadioLabel}
<% if $FieldList %>
$FieldHolder
<% end_if %>
</li>
<% end_loop %>
</ul>