Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Problem/Motivation
After installing maxlength on my site, I observed that while it works well for new data, old data that exceeds the newly determined field length is not truncated.
Proposed resolution
Truncate the text field on form_alter prior to displaying it to the user.
Remaining tasks
Verify the to-be-attached patch and determine if the method is acceptable.
User interface changes
Perhaps add a setting to allow users to turn the truncation option on and off?
Comment | File | Size | Author |
---|---|---|---|
#2 | preexisting_text_not-2834483-2.patch | 1.37 KB | merauluka |
Comments
Comment #2
merauluka CreditAttribution: merauluka commentedComment #3
KingdutchI just want to chime in that I think this is how the module should function. Altering existing user data when enabling this is probably a jarring experience and could experience to data loss. It's probably better not to touch existing data and let the user decide how to deal with it. That might mean that a user has to revisit each existing node if they want to data to be made shorter. However, if the text is arbitrarily cut off after a certain amount of characters then the user will have to do that anyway because texts on their sites will suddenly
Comment #4
realityloopIsn't this more safely implemented by truncating the output rather than choping the saved data without the user realising?
Comment #5
larowlanThis feels like a site-specific concern that could be handled in an update hook we don't want to be causing data-loss.