omeka/plugin-CollectionTree — Issue #7: Represent collection hierarchy in collection select form
Author: jimsafley
Created: 2011-11-15 21:29:22+00:00
State: open

On [this discussion](http://groups.google.com/group/omeka-dev/browse_thread/thread/fc1fe07b8147202c), Jeremy made the following suggestion:

>Looks like this would be a great opportunity to add a filter to the collections select menu on the Item form. (LIkely just have a filter for _select_from_table). Having a list of nested collections separate from the form input where you actually choose the collection is less than ideal.

This will be a two step process. First, in Omeka core, filter the select options returned from `findPairsForSelectForm()`, using something like this (note the `apply_filters()`):

```php
getTable($tableClass)->findPairsForSelectForm($searchParams);
$options = apply_filters(Inflector::underscore($tableClass) . '_select_options', $options);
return select($props, $options, $value, $label);
}
```
Second, in the CollectionTree plugin, add a `collections_select_options` filter callback that returns the collection hierarchy represented as a one-dimensional array where individual characters (probably spaces) represent the collection depth. For example:

```php
"Collection One",
3 => " Collection Three",
4 => " Collection Four",
6 => " Collection Six",
2 => "Collection Two",
5 => " Collection Five",
)
```
This way the collection select form on the item add/edit page will be easier to use.