public function updateCMSFields(FieldList $fields)
    {
        Requirements::javascript('marketplace/code/ui/admin/js/openstack.release.supported.api.version.admin.ui.js');
        $fields->removeByName('ApiVersionID');
        $versions = OpenStackApiVersion::get()->map('ID', 'Version');
        $ddl = new DropdownField('ApiVersionID', 'API Version', $versions);
        $ddl->addExtraClass('ddl-api-version-id');
        $ddl->setEmptyString('--Select An API Version --');
        $fields->insertAfter($ddl, 'OpenStackComponentID');
        $versions = array();
        foreach (OpenStackComponent::get()->filter('SupportsVersioning', true) as $component) {
            foreach ($component->getVersions() as $version) {
                if (!array_key_exists(intval($component->getIdentifier()), $versions)) {
                    $versions[intval($component->getIdentifier())] = array();
                }
                array_push($versions[intval($component->getIdentifier())], array('value' => intval($version->getIdentifier()), 'text' => $version->getVersion()));
            }
        }
        $json_data = json_encode($versions);
        $script = <<<JS
\t\t<script>
\t\tvar versions = {$json_data};
\t\t</script>
JS;
        $fields->add(new LiteralField('js_data', $script));
        $fields->removeByName('OpenStackComponentID');
        //kludge; get parent id from url....
        $url = preg_split('/\\//', $_REQUEST['url']);
        $release_id = (int) $url[8];
        //components
        $components = OpenStackComponent::get()->filter('SupportsVersioning', true)->innerJoin('OpenStackRelease_OpenStackComponents', "OpenStackRelease_OpenStackComponents.OpenStackComponentID = OpenStackComponent.ID AND OpenStackReleaseID = {$release_id} ");
        $components_source = array();
        foreach ($components as $comp) {
            $components_source[$comp->ID] = sprintf('%s (%s)', $comp->Name, $comp->CodeName);
        }
        $ddl = new DropdownField('OpenStackComponentID', 'OpenStack Component', $components_source);
        $ddl->setEmptyString('--Select A OS Component--');
        $ddl->addExtraClass('ddl-os-component-id');
        $fields->insertBefore($ddl, 'ApiVersionID');
        $fields->insertAfter(new TextField("ReleaseVersion", "Release Version"), 'ReleaseID');
        $fields->insertAfter(new LiteralField('ReleaseVersionTitle', '<p>You could get this data from <a href="http://docs.openstack.org/releases" target="_blank">http://docs.openstack.org/releases</a></p>'), 'ReleaseVersion');
        return $fields;
    }
 /**
  * @param int $id
  * @param int $component_id
  * @return IOpenStackApiVersion
  */
 public function getByIdAndComponent($id, $component_id)
 {
     return OpenStackApiVersion::get()->filter(array('ID' => $id, 'OpenStackComponentID' => $component_id))->first();
 }