Select input Using Dublin Core Type values

Trying to build a form element select where the options are key=>value pairs drawn from Dublin Core metadata already created by users. It will go to the advanced search.

Here’s the query I want to run:
SELECT distinct text FROM mow.omeka_element_texts where element_id=51

Not sure if this is the right Omeka function, and not sure how to define $options
findPairsForSelectForm ([ $options = array()])
is this handled by _getcolumnpairs()?

open to an easier way of doing this, but $this->formSelect() documentation is more or less nil, and wading through the documentation on filters really doesn’t solve the issue because it’s overkill. I just want to build a form element that can harness the metadata browser and produce a uri like

http://agile-mow/items/browse?advanced[0][element_id]=51&advanced[0][type]=is+exactly&advanced[0][terms]=Nib

Anyone got any hints?

formSelect is just the Zend helper, so such documentation as exists for it is in Zend’s manual page on view helpers.

Since you really just want to run a query and get the results back, it’s probably easier for you to not try to use the findPairs stuff… that’s really for getting results back from a whole table (the collections indexed by ID, for example). You can do filtering on it, but you’d be looking at introducing that into a core table that doesn’t currently have it (the element texts) and that’s not really how it’s designed to be done.

Instead, you could just do a function or helper of your own: with get_db you get the DB Adapter object and can just directly execute a query on it. fetchCol('your sql') will return the first (in this case only) column of the result set in a single-dimensional array, and you can easily feed that to the formSelect view helper.

Thanks I managed to get this off the DB object with fetchCol().

The larger issue, however, is getting the selection to play nicely with the advanced search functionality. I understand that the approach for form elements with Omeka has been to use jQuery to hide form inputs. However, I want to use the select element above to produce an advanced search result page from the search by metadata plugin (http://omeka.org/add-ons/plugins/search-by-metadata/).

At the moment the only effective workaround I can envisage is to have an onchange function with two hidden elements that populate or empty their values dependent upon the search term selected in the select box, and use the $_GET data for capturing the selected option if it’s present.

There’s no form builder for single metadata fields that integrates well with the usual search term form builders, right?

I’m not sure from your description what you’re looking to do. Are you trying to integrate into the existing advanced search, make a new simpler search form, or have this “search” live somewhere else entirely?

The URL you gave as an example in the first post is just a standard “advanced” search, as used both by the regular search form and the Search By Metadata plugin. I’m not sure exactly what you’re getting at with the mention of dynamically updating hidden fields, but it doesn’t seem necessary to me at first glance.

Ended up doing this. Not pretty, but it works.

<?php //there is no Omeka form builder for search by metadata fields!
echo $this->formLabel('item-type-search', __('Search By Category')); ?>
<div class="inputs"><select id="advancedmetadatasearchterms" name="advanced[0][terms]">
<option>Selet Below</option>
<?php $omekadb=get_db();
$stuff=$omekadb->fetchCol('SELECT distinct text FROM mow.omeka_element_texts where element_id=51 order by text');
foreach($stuff as $category){?>
<option value="<?php echo $category;?>" <?php if($_GET['advanced'][0]['terms']==$category){ print "selected";}?>><?php echo $category;?></option><?php }?></select>
<input type="hidden" value="<?php if(isset($_GET['advanced'][0]['terms'])){ print $_GET['advanced'][0]['element_id'];}?>" id="advancedmetadatasearchelement_id" name="advanced[0][element_id]">
<input type="hidden" value="<?php if(isset($_GET['advanced'][0]['terms'])){ print $_GET['advanced'][0]['type'];}?>" id="advancedmetadatasearchtype" name="advanced[0][type]">
<script>
jQuery(function(){
	jQuery('#advancedmetadatasearchterms').change(function(){
		var advancedmetadataterm=jQuery('#advancedmetadatasearchterms').val();
		if(advancedmetadataterm!=''){
			jQuery('#advancedmetadatasearchelement_id').val('51');
			jQuery('#advancedmetadatasearchtype').val('is exactly');
		}else{
			jQuery('#advancedmetadatasearchelement_id').val('');
			jQuery('#advancedmetadatasearchtype').val('');
		}
	});
});
</script>
</div>