mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-30 13:19:11 +02:00
Consistent API for SelectionGroup constructor.
This commit is contained in:
parent
85b00105ce
commit
87b5451d2d
@ -29,13 +29,19 @@ class SelectionGroup extends CompositeField {
|
|||||||
/**
|
/**
|
||||||
* Create a new selection group.
|
* Create a new selection group.
|
||||||
*
|
*
|
||||||
* @param name The field name of the selection group.
|
* @param string $name The field name of the selection group.
|
||||||
* @param items The list of {@link SelectionGroup_Item}
|
* @param array $items The list of {@link SelectionGroup_Item}
|
||||||
|
* @param mixed $value
|
||||||
*/
|
*/
|
||||||
public function __construct($name, $items) {
|
public function __construct($name, $items, $value = null) {
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
|
|
||||||
|
if($value !== null) {
|
||||||
|
$this->setValue($value);
|
||||||
|
}
|
||||||
|
|
||||||
$selectionItems = array();
|
$selectionItems = array();
|
||||||
|
|
||||||
foreach($items as $key => $item) {
|
foreach($items as $key => $item) {
|
||||||
if($item instanceof SelectionGroup_Item) {
|
if($item instanceof SelectionGroup_Item) {
|
||||||
$selectionItems[] = $item;
|
$selectionItems[] = $item;
|
||||||
|
Loading…
Reference in New Issue
Block a user