def _clean_tag(self, tag):
"""Sanitize tag."""
+ if not isinstance(tag, types.StringType):
+ if len(tag) == 2 and '' in tag:
+ # User used either dropdown or textbox
+ tag.remove('')
+ tag = tag[0]
+ else:
+ # User used both dropdown and textbox
+ return None
m = self.tag_regexp.match(tag)
if m != None:
return m.group()
</span><br />
{% endif %}
</p>
- <form action="add_tag" method="post">
+ <form action="add_tag" method="get">
<input type="hidden" name="name" value="{{ recipe.name }}"/>
+ <select name="tag">
+ <option value="">textbox</option>
+ {% for tag in cookbook.tags() %}
+ <option value="{{ tag }}">{{ tag }}</option>
+ {% endfor %}
+ </select>
<input type="text" name="tag" value=""/>
<input type="submit" value="Add tag" />
</form>
- <form action="remove_tag" method="post">
+ {% if recipe.tags %}
+ <form action="remove_tag" method="get">
<input type="hidden" name="name" value="{{ recipe.name }}"/>
- <input type="text" name="tag" value=""/>
+ <select name="tag">
+ {% for tag in recipe.tags %}
+ <option value="{{ tag }}">{{ tag }}</option>
+ {% endfor %}
+ </select>
<input type="submit" value="Remove tag" />
</form>
+ {% endif %}
<div id="recipe-ingredient-blocks">
{% for ingredient_block in recipe.ingredient_blocks %}