Ticket #8627: fix_textarea_disappearing_first_empty_line.diff
File fix_textarea_disappearing_first_empty_line.diff, 4.4 KB (added by , 16 years ago) |
---|
-
django/forms/widgets.py
282 282 if value is None: value = '' 283 283 value = force_unicode(value) 284 284 final_attrs = self.build_attrs(attrs, name=name) 285 return mark_safe(u'<textarea%s> %s</textarea>' % (flatatt(final_attrs),285 return mark_safe(u'<textarea%s>\r\n%s</textarea>' % (flatatt(final_attrs), 286 286 conditional_escape(force_unicode(value)))) 287 287 288 288 class DateTimeInput(Input): -
tests/modeltests/model_forms/models.py
350 350 <option value="1">Mike Royko</option> 351 351 <option value="2">Bob Woodward</option> 352 352 </select></td></tr> 353 <tr><th>Article:</th><td><textarea rows="10" cols="40" name="article"></textarea></td></tr> 353 <tr><th>Article:</th><td><textarea rows="10" cols="40" name="article"> 354 </textarea></td></tr> 354 355 <tr><th>Status:</th><td><select name="status"> 355 356 <option value="" selected="selected">---------</option> 356 357 <option value="1">Draft</option> … … 405 406 <option value="1" selected="selected">Mike Royko</option> 406 407 <option value="2">Bob Woodward</option> 407 408 </select></li> 408 <li>Article: <textarea rows="10" cols="40" name="article">Hello.</textarea></li> 409 <li>Article: <textarea rows="10" cols="40" name="article"> 410 Hello.</textarea></li> 409 411 <li>Status: <select name="status"> 410 412 <option value="" selected="selected">---------</option> 411 413 <option value="1">Draft</option> … … 466 468 <option value="1" selected="selected">Mike Royko</option> 467 469 <option value="2">Bob Woodward</option> 468 470 </select></li> 469 <li>Article: <textarea rows="10" cols="40" name="article">Hello.</textarea></li> 471 <li>Article: <textarea rows="10" cols="40" name="article"> 472 Hello.</textarea></li> 470 473 <li>Status: <select name="status"> 471 474 <option value="" selected="selected">---------</option> 472 475 <option value="1">Draft</option> … … 582 585 <option value="1">Mike Royko</option> 583 586 <option value="2">Bob Woodward</option> 584 587 </select></li> 585 <li>Article: <textarea rows="10" cols="40" name="article"></textarea></li> 588 <li>Article: <textarea rows="10" cols="40" name="article"> 589 </textarea></li> 586 590 <li>Status: <select name="status"> 587 591 <option value="" selected="selected">---------</option> 588 592 <option value="1">Draft</option> … … 608 612 <option value="2">Bob Woodward</option> 609 613 <option value="3">Carl Bernstein</option> 610 614 </select></li> 611 <li>Article: <textarea rows="10" cols="40" name="article"></textarea></li> 615 <li>Article: <textarea rows="10" cols="40" name="article"> 616 </textarea></li> 612 617 <li>Status: <select name="status"> 613 618 <option value="" selected="selected">---------</option> 614 619 <option value="1">Draft</option> -
tests/regressiontests/forms/forms.py
303 303 >>> print f['subject'] 304 304 <input type="text" name="subject" /> 305 305 >>> print f['message'] 306 <textarea rows="10" cols="40" name="message"></textarea> 306 <textarea rows="10" cols="40" name="message"> 307 </textarea> 307 308 308 309 as_textarea(), as_text() and as_hidden() are shortcuts for changing the output 309 310 widget type: 310 311 >>> f['subject'].as_textarea() 311 u'<textarea rows="10" cols="40" name="subject"> </textarea>'312 u'<textarea rows="10" cols="40" name="subject">\r\n</textarea>' 312 313 >>> f['message'].as_text() 313 314 u'<input type="text" name="message" />' 314 315 >>> f['message'].as_hidden() … … 320 321 ... message = CharField(widget=Textarea(attrs={'rows': 80, 'cols': 20})) 321 322 >>> f = ContactForm(auto_id=False) 322 323 >>> print f['message'] 323 <textarea rows="80" cols="20" name="message"></textarea> 324 <textarea rows="80" cols="20" name="message"> 325 </textarea> 324 326 325 327 Instance-level attrs are *not* carried over to as_textarea(), as_text() and 326 328 as_hidden(): … … 328 330 u'<input type="text" name="message" />' 329 331 >>> f = ContactForm({'subject': 'Hello', 'message': 'I love you.'}, auto_id=False) 330 332 >>> f['subject'].as_textarea() 331 u'<textarea rows="10" cols="40" name="subject"> Hello</textarea>'333 u'<textarea rows="10" cols="40" name="subject">\r\nHello</textarea>' 332 334 >>> f['message'].as_text() 333 335 u'<input type="text" name="message" value="I love you." />' 334 336 >>> f['message'].as_hidden()