Changes between Version 5 and Version 6 of GenshiRecipes/FormFilling
- Timestamp:
- Sep 24, 2006, 6:38:54 PM (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GenshiRecipes/FormFilling
v5 v6 6 6 #!xml 7 7 <html xmlns:py="http://genshi.edgewall.org/"> 8 8 9 9 <input py:match="form//input[@type='text']" py:attrs="select('@*')" 10 10 value="${form.get(str(select('@name')))}" /> … … 16 16 <textarea py:match="form//textarea" py:attrs="select('@*')" 17 17 py:content="form.get(str(select('@name')))"></textarea> 18 <select py:match="form//select" py:attrs="select('@*')" 19 py:with="select_name = str(select('@name'))" 20 py:content="select('option|optgroup')" /> 21 <option py:match="form//select//option" py:attrs="select('@*')" 22 py:with="sel_value = form.get(select_name)" 23 selected="${sel_value and (str(select('@value')) == sel_value) or None}" 24 py:content="select('@value')" /> 18 25 19 26 <form action="" method="POST"> … … 38 45 </label> 39 46 </fieldset> 47 <!--! A select box --> 48 <p> 49 <label>Select another: 50 <select name="dropdown"> 51 <option py:for="option in range(1, 4)" value="$option">$option</option> 52 </select> 53 </label> 54 </p> 40 55 </form> 41 56 </html> … … 49 64 'enable': '', 50 65 'option': 'B', 51 'description': 'This is the description someone put in here'} 66 'description': 'This is the description someone put in here', 67 'dropdown': '2'} 52 68 }}} 53 69 … … 80 96 </label> 81 97 </fieldset> 98 <p> 99 <label>Select another: 100 <select name="dropdown"> 101 <option value="1">1</option> 102 <option selected="selected" value="2">2</option> 103 <option value="3">3</option> 104 </select> 105 </label> 106 </p> 82 107 </form> 83 108 </html> 84 109 }}} 85 110 86 This recipe would need to be extended to also support select fields.87 88 111 ---- 89 112 See also: GenshiRecipes, [wiki:Documentation/xml-templates.html Genshi XML Template Language]