backdrop / backdrop-issues

Issue tracker for Backdrop core.
144 stars 39 forks source link

Trim textfields? #6386

Open alanmels opened 7 months ago

alanmels commented 7 months ago

In almost every Backdrop project at AltaGrade, we find it necessary to trim all textfields using a custom hook. This is because users often leave empty spaces at the beginning or end of their entries. While it may not be a significant issue for textfields like names, as it might only disrupt alphabetical ordering, it becomes more critical for fields that can accept mixed values such as text, integers, and floats. This can affect calculations and lead to more serious consequences. Therefore, I briefly considered the idea of having every textfield entry trimmed by the core. This could be a beneficial solution without causing any known issues. However, I acknowledge that this is just my opinion, and I welcome everyone to share their insights on this matter.

argiepiano commented 7 months ago

I think this is a good idea. Wondering if it may be worth exploring this as a contrib module first?

avpaderno commented 7 months ago

I would like to have the option to automatically trim the content of text fields, but I would still make it disabled by default.

avpaderno commented 7 months ago

For Drupal, there is the Trim module. I guess that means we could first port that module to Backdrop, as contributed module, as @argiepiano suggested.

avpaderno commented 7 months ago

(Actually, that module trims every submitted string value; it does not check which form element was used to submit the value, contrary to what the project page makes you think. Probably it is not the right module to take as example.)

lourdas commented 7 months ago

Although I cannot think of a valid user case, it might be in the user's intention to have a starting or maybe ending space character... But in the end, I agree with @alanmels.

argiepiano commented 7 months ago

This could be a setting at the field level for text fields - whether white space is trimmed or not.