alphagov/transition — pull request #26 by rgarner (2013-07-12 13:30:59+00:00)
Title: Content type dropdown

Ok, so what you get is a basic dropdown annotated with `subtype` and `optgroup` classes. These were originally intended to simulate `optgroup` styling, but where the top level was not really an optgroup (for example 'Policy', which has no subtype, but needs to be selectable, so isn't really a 'group'). Where I tripped myself up here was forgetting that you can't style an `
` (at least not without resorting to JS, which is the only reason why the `.optgroup` and `.subtype` classes remain).

Then I looked at the data again and realised real `optgroup` tags need to be created on the first encounter with a type (assuming the `ContentType` list passed is ordered by type). Unfortunately I've failed to make this work with the motley collection of Rails `options_for` methods, which are, as Tom says, "bananas" and all of which seem not amenable to easy extension.