1

Just now i've discovered that my operator was entering many times organization name prefixed/suffixed with a space. For example " Microsoft" or "Microsoft ".

That is causing problem when this value is being passed as contextual arguments in the views with this space character making a difference.

I need help as to how I can trim already fed in text and secondly store only trimmed version of text.

I could only find this useful page about this issue.

1 Answer 1

3

To correct all those values entered into the database already, I'd suggest doing a mysql trim on those values and resetting them. Make sure you backup the tables first of course, but something like this should do it (if your field name is field_text_test):

UPDATE field_data_field_text_test SET field_text_test_value = TRIM(field_text_test_value);
UPDATE field_revision_field_text_test SET field_text_test_value = TRIM(field_text_test_value);

After you've run those statements, do a flush all caches on your drupal site.

And then to avoid this happening again, you could use the Form API Validation module which adds a trim filter on fields.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.