mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
commit
f3c3562fdc
@ -47,13 +47,14 @@ class CompositeField extends FormField {
|
|||||||
if($children instanceof FieldList) {
|
if($children instanceof FieldList) {
|
||||||
$this->children = $children;
|
$this->children = $children;
|
||||||
} elseif(is_array($children)) {
|
} elseif(is_array($children)) {
|
||||||
$this->children = new FieldList($children);
|
$this->children = new FieldList($children);
|
||||||
} else {
|
} else {
|
||||||
$children = is_array(func_get_args()) ? func_get_args() : array();
|
//filter out null/empty items
|
||||||
$this->children = new FieldList($children);
|
$children = array_filter(func_get_args());
|
||||||
|
$this->children = new FieldList($children);
|
||||||
}
|
}
|
||||||
$this->children->setContainerField($this);
|
$this->children->setContainerField($this);
|
||||||
|
|
||||||
// Skipping FormField::__construct(), but we have to make sure this
|
// Skipping FormField::__construct(), but we have to make sure this
|
||||||
// doesn't count as a broken constructor
|
// doesn't count as a broken constructor
|
||||||
$this->brokenOnConstruct = false;
|
$this->brokenOnConstruct = false;
|
||||||
|
@ -13,7 +13,10 @@
|
|||||||
<ul class="SelectionGroup<% if extraClass %> $extraClass<% end_if %>">
|
<ul class="SelectionGroup<% if extraClass %> $extraClass<% end_if %>">
|
||||||
<% loop $FieldSet %>
|
<% loop $FieldSet %>
|
||||||
<li$Selected>
|
<li$Selected>
|
||||||
{$RadioButton}{$RadioLabel}{$FieldHolder}
|
{$RadioButton}{$RadioLabel}
|
||||||
|
<% if $FieldList %>
|
||||||
|
$FieldHolder
|
||||||
|
<% end_if %>
|
||||||
</li>
|
</li>
|
||||||
<% end_loop %>
|
<% end_loop %>
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
Reference in New Issue
Block a user