Zope ZPT Select box options looped over dictionary

Display a select box who's label and values are based on keys and values in a dictionary.
<div class="field" 
     tal:define="options python:{'Sales': '[email protected]', 
				 'Customer Service': '[email protected]', 
				 'Claims' : '[email protected]'">
	<label for="sendto">Who</label>
	<select name="sendto" id="sendto">
	<tal:loop repeat="option python:options.keys()">
		<option tal:attributes="value python: options[option]; 
		  selected python: test(request.get('sendto','') == options[option], 'true','')" 
		  tal:content="option" />
	</tal:loop>						
	</select>
</div>
Snippet Viewed 1866 times.

Share your Zope ZPT code snippets:

  • Get some recognition & link back to your site.

 

Submit | Browse

Most Recent zope zpt snippets

Most Viewed