Jump to content

Check if textarea field is RTE or not


Loges
 Share

Recommended Posts

Hi,

 

I've spent ages trying to work this out, so I'm hoping someone knows the answer.

 

I'm writing a class to handle form submission to textarea fields.  Sometimes it will be an RTE (CKEditor) field and sometimes it'll be plaintext textarea and I'm wanting to purify/sanitize whilst keeping line breaks.

 

I *think* I've got solutions for both but for the life of me I can't figure out how to get info on the target field via the API on whether it's a field that uses the RTE or not.  I'm hoping I should be able to do a check against the field's inputfieldClass but I can't see how to access that property from the API.

 

Any help appreciated (or if there's a sanitize/purify option that works for both that's even better).  Best I can get so far is

 $wiresanitizerpurify$inputstr

 

$cleaned = $wire->sanitizer->textarea($inputstr, ['multiLine' => false, 'newlineReplacement' => "<br/>", 'stripTags' => false]); //for RTE textarea fields
Link to comment
Share on other sites

34 minutes ago, Loges said:

I'm hoping I should be able to do a check against the field's inputfieldClass but I can't see how to access that property from the API.

You access it like any other property of the field...

2018-04-19_210343.png.6c0cf694f5b28493ee5a0b2c2f8d7399.png

...or am I misunderstanding your question?

 

  • Like 2
Link to comment
Share on other sites

Thanks, I really don't know why I couldn't get that working.  I tried that previously.  Came back with your answer tried again and it's working.

 

An attack of those 'walk away and come back later' moments.

 

Thanks very much for the speedy reply.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...