Hi guys,
Is there an easier way to convert a DropdownField to a SelectionGroup from an enum field?
Maybe something like this?
$fields = $this->scaffoldFormFields(
array(
'fieldClasses' => array(
'SomeField' => 'SelectionGroup',
)
)
);
or do have to do this?
$name = $fields->dataFieldByName('SomeField')->getAttributes()["name"];
$values = $fields->dataFieldByName('SomeField')->getSource();
$items = array();
foreach($values as $value) {
$items[] = SelectionGroup_Item::create($value, null, $value);
}
$convertedField = SelectionGroup::create($name, $items);
$fields->push($convertedField);