Trimming a space in a Post

Options
One field in my table needs to ensure there are no spaces. It will be used as a public facing URL appended to a page such as:

website.com/[field_input]

...where [field_input] is the displayed data from the specific field of the table. When a POST call is made, I need to ensure there are no spaces at all - I've figured out how to ensure all characters are lowercase within the Function stack.

Comments

  • Lukasz Kwiatkowski
    Options
    you have a trim function for text which removes first and last spaces, not sure if this helps...
    otherwise if you cannot have any spaces you can split text into array with " " as a separator and then join it again without spaces
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    There are also trim filters that you can take advantage of:

    [CleanShot 2021-11-15 at 17.45.24.png]
  • Matt
    Matt Member
    Options
     These only appear to work for the beginning or end, based on my attempts at using them. I'd need to ensure there are no spaces between characters as well. The goal here is that it would be intentionally a page URL format.
  • Lukasz Kwiatkowski
    Options
    why wont you try URL encoding filter?
    otherwise as suggested before split array with space " " separator and join all elements as 1 string 
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    Trimming is always going to be on the ends. Perhaps, look at url_encode per  suggestion. Also, there is a replace filter that you can use to replace spaces with nothing. 
  • Matt
    Matt Member
    Options
    Thanks guys. I'll play around with these options and report back later.