| 242 | Show the form for a new Car. Note that steering field doesn't include the blank choice, |
| 243 | because the field is obligatory and has an explicit default. |
| 244 | >>> CarForm = form_for_model(Car) |
| 245 | >>> f = CarForm(auto_id=False) |
| 246 | >>> print f |
| 247 | <tr><th>Name:</th><td><input type="text" name="name" maxlength="50" /></td></tr> |
| 248 | <tr><th>Steering:</th><td><select name="steering"> |
| 249 | <option value="left" selected="selected">Left steering wheel</option> |
| 250 | <option value="right">Right steering wheel</option> |
| 251 | </select></td></tr> |
| 252 | <tr><th>Fuel:</th><td><select name="fuel"> |
| 253 | <option value="" selected="selected">---------</option> |
| 254 | <option value="gas">Gasoline</option> |
| 255 | <option value="diesel">Diesel</option> |
| 256 | <option value="other">Other</option> |
| 257 | </select></td></tr> |
| 258 | <tr><th>Transmission:</th><td><select name="transmission"> |
| 259 | <option value="" selected="selected">---------</option> |
| 260 | <option value="at">Automatic</option> |
| 261 | <option value="mt">Manual</option> |
| 262 | <option value="cvt">CVT</option> |
| 263 | </select><br />Leave empty if not applicable.</td></tr> |
| 264 | |
| 265 | Create a Car, and display the form for modifying it. Note that now the fuel |
| 266 | selector doesn't include the blank choice as well, since the field is |
| 267 | obligatory and can not be changed to be blank. |
| 268 | >>> honda = Car(name='Honda Accord Wagon', steering='right', fuel='gas', transmission='at') |
| 269 | >>> honda.save() |
| 270 | >>> HondaForm = form_for_instance(honda) |
| 271 | >>> f = HondaForm(auto_id=False) |
| 272 | >>> print f |
| 273 | <tr><th>Name:</th><td><input type="text" name="name" value="Honda Accord Wagon" maxlength="50" /></td></tr> |
| 274 | <tr><th>Steering:</th><td><select name="steering"> |
| 275 | <option value="left">Left steering wheel</option> |
| 276 | <option value="right" selected="selected">Right steering wheel</option> |
| 277 | </select></td></tr> |
| 278 | <tr><th>Fuel:</th><td><select name="fuel"> |
| 279 | <option value="gas" selected="selected">Gasoline</option> |
| 280 | <option value="diesel">Diesel</option> |
| 281 | <option value="other">Other</option> |
| 282 | </select></td></tr> |
| 283 | <tr><th>Transmission:</th><td><select name="transmission"> |
| 284 | <option value="">---------</option> |
| 285 | <option value="at" selected="selected">Automatic</option> |
| 286 | <option value="mt">Manual</option> |
| 287 | <option value="cvt">CVT</option> |
| 288 | </select><br />Leave empty if not applicable.</td></tr> |
| 289 | |