Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim textfields? #6386

Open
alanmels opened this issue Jan 27, 2024 · 6 comments
Open

Trim textfields? #6386

alanmels opened this issue Jan 27, 2024 · 6 comments

Comments

@alanmels
Copy link

alanmels commented Jan 27, 2024

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
Copy link

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

@kiamlaluno
Copy link
Member

kiamlaluno commented Jan 27, 2024

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

@kiamlaluno
Copy link
Member

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.

@kiamlaluno
Copy link
Member

(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
Copy link

lourdas commented Jan 29, 2024

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants