#19226 closed Bug (fixed)
Admin readonly fields ignore newlines
Reported by: | shadow | Owned by: | Lebedev Ilya |
---|---|---|---|
Component: | contrib.admin | Version: | 1.4 |
Severity: | Normal | Keywords: | |
Cc: | atodorov@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
A TextField that is marked as readonly in the Admin will be displayed in a simple <p>, effectively removing any newlines that were entered. Since in HTML, <textarea> displays newlines as you enter them, it would be more appropriate if <pre> were used to display the data when it is readonly.
See: contrib/admin/templates/admin/includes/fieldset.html:17
thanks
Attachments (4)
Change History (21)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 12 years ago
Owner: | changed from | to
---|
by , 12 years ago
Attachment: | ticket_19226.diff added |
---|
comment:4 by , 12 years ago
Has patch: | set |
---|
comment:5 by , 12 years ago
Status: | new → assigned |
---|
comment:6 by , 12 years ago
Needs tests: | set |
---|
I think you could tweak the existing test_readonly_get
in admin_views tests to include a new line in some value.
by , 12 years ago
Attachment: | ticket_19226.2.diff added |
---|
comment:7 by , 12 years ago
Needs tests: | unset |
---|
comment:8 by , 12 years ago
You are near, but you have tested a non-readonly field, otherwise the test would have failed (as you should get <br> instead of newlines).
by , 12 years ago
Attachment: | ticket_19226.3.diff added |
---|
comment:9 by , 12 years ago
I fixed the last patch so that it actually executes and added an assertion that the conversion into <br /> tags was actually made.
comment:10 by , 12 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:11 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:13 by , 12 years ago
Yep guys,
I've found that this is not fixed for inlines. I've opened this ticket: #19429
comment:14 by , 11 years ago
Resolution: | fixed |
---|---|
Status: | closed → new |
Hi guys,
this fix is breaking up display for me. I'm using computed read-only fields which display rich HTML into the model change form as a way to augment the administration experience which works really well for me.
Adding multiple line break tags breaks my display (this only happens because the templates used to render the fields have new lines in them). Now I have to go all-over my code and strip new lines before returning the field value.
It would be nice if the linebreaks filter skipped \n, <br/> replacement on safe strings.
comment:15 by , 11 years ago
Cc: | added |
---|
comment:16 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Hi, could you please open a new ticket (referencing this one) with your use case instead of reopening a rather old ticket? And it would probably help understanding of your issue if you can provide some code example, maybe even screenshots.
A nicer solution (rather than <pre>) might be:
As this avoids the other styling that goes along with <pre>