1

My client needs to input apostrophes in text fields for staff names, such as ’ or just the plain ' and as you can imagine, it is causing issues.

I have tried this replace({'\'',''}) and this replace({'\’',''}) but to no success. Thoughts?

  • 3
    Can you be more specific describing the problem, isral? Plain Text fields should handle straight or curly apostrophes just fine without any special handling, and I believe Rich Text fields should be no different. I'm struggling to understand why the client inputting them is a problem and why you're attempting to remove them at the template level. – Matt Stein Jun 6 '17 at 22:46
  • Hi, @MattStein. i am removing them at the template level because i use thise text fields to create IDs which are targeted in JS/jQ. For example, if the field has "First L'ast" then JS won't be able to get the IDs because they become something like data-target="firstl'ast". – isral Jun 7 '17 at 23:40
1

As it happens, this solved my issue: {{ personfirstandlastname|replace({'\'':''}) }}

EDIT

To clarify, this isn't a valid Twig object:

{'\'',''}

... while this is:

{'\'':''}
|improve this answer|||||
  • 1
    Wasn't that what you described specifically not working in your question? edit: nevermind, I see the , became a : – Matt Stein Jun 7 '17 at 23:57
  • @MattStein i will be increasing text sizes in my browser. – isral Jun 8 '17 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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