Skip Navigation

[Resolved] Properties of Text Area field

This support ticket is created 6 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 9 replies, has 2 voices.

Last updated by Christian Cox 6 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#561639

Hi there,

I have tried looking for this, but not able to find it.

Can you tell me please, what are the properties of the text area field?

I have a field created in Types which is a Text Area, and on the front end users are able to submit posts with information in that field using a CRED form.

But I want to be able to say to them in the field description which html tags are allowed. I see that the STRONG tag is definitely allowed. Is there a reference for all that is allowed, and any other properties of the field (particularly in use on the front end with CRED)?

Then, as a supplementary question: Is there a way to make a button so that if a user wants to bold some text, they can press that rather than have to use html tags? Some users will not feel confident with that.

Many thanks for your time.

#561743

Is there a reference for all that is allowed, and any other properties of the field (particularly in use on the front end with CRED)?
Script tags will be stripped out, but any other HTML tag in a multiline field will be stored in the database.
Options for the cred_field shortcode are documented over here:
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field
Options for displaying the value of a textarea using a shortcode:
https://toolset.com/documentation/customizing-sites-using-php/functions/#textarea

Then, as a supplementary question: Is there a way to make a button so that if a user wants to bold some text, they can press that rather than have to use html tags?
You would have to write a significant amount of custom code to make this work. We offer a WYSIWYG field type that includes many formatting options, but we do not currently support any formatting options in a Textarea / Multiline field.

#563196
Screen Shot 2017-08-24 at 08.55.46.png

Hi Christian,

Many thanks for getting back to me on this one.

Dealing with the last point first (i.e. applying formatting buttons in non-wysiwyg text area fields), no problem. There is probably no reason for me to complicate things in that way. So we'll drop that.

Now onto the main point: is there a reference explaining which tags are allowed to be used in multiline textarea fields with CRED

You said that script tags will be stripped out, but all other HTML tags entered in CRED to a multiline field will be stored in the database. You provided me with two links to documentation as follows:

So my first question: How I would use this in my php so that the HTML tags entered by the user in the multiline textarea field have effect on the front end (e.g. so anything wrapped in a strong tag by the user appears in bold on the post when someone views it)?

I guess it is something to do with this item on the second link you provided, and that I would be using the 'html' option:

output:
'raw' | 'html' | 'normal'(default)
'raw'=display raw data stored in DB, 'html'=wrap data in HTML

...is that correct? If so, I could just use some help on structuring the php correctly and what needs to be added to this code:

types_render_field( "my-textarea", array( ) )

My best guess is that the code would need to be structured as follows, but your advice would be great please:

types_render_field( "my-textarea", array( "output" => "html" ) )

...am I even close?

Finally, you will see in the attached image what you on your own site display beneath the text area field I am typing in right now. This explains to users exactly which tags are allowed. So are they the full list of allowed tags, or can users use other tags, too (e.g. anchor tags, ordered lists, image tags, etc). And if they do so, will those tags have the expected result when someone views the post on the website if I use the correct code in my php?

Thanks again for your time and support.

Very best wishes,
Andrew.

#563244

(e.g. so anything wrapped in a strong tag by the user appears in bold on the post when someone views it)?
Well "bold" is visual formatting, which is handled by CSS. The strong tag doesn't necessarily affect the visual formatting of its contents - normally, but not always. You may need to use CSS to format specific tags in specific ways. Usually a custom theme has some baseline formatting, but you can supplement or override those using your own custom CSS.

I guess it is something to do with this item on the second link you provided, and that I would be using the 'html' option
You will most likely use the "raw" option. The "html" option will wrap the saved code in some additional HTML tags, which you will not need. So I would tweak your example like this:

types_render_field( "my-textarea", array( "output" => "raw" ) );

And if they do so, will those tags have the expected result when someone views the post on the website if I use the correct code in my php?
If you render the raw output, tags stored in the database will be output in the source of your page. I think the expected result is a bit subjective, and may require some additional CSS to format the output as desired.

#563249
Screen Shot 2017-08-24 at 08.55.46.png

Hi Christian,

Thanks for your response.

I'm aware about the CSS etc re strong/bold. It was a manner of speaking and the css in this theme does make anything with the strong tag appear in bold. CSS I'm fine with (that's my job) I just need help with getting the php function right so that the browser is sent the desired source code for me to style in my CSS.

So with that in mind, if I use this code below then the scenario I desire should work, and the tags entered by the user in the CRED textarea field would be styled in the live post according to my CSS, yes?

types_render_field( "my-textarea", array( "output" => "raw" ) );

Am I now on the right lines?

Separately I still don't have an answer to this part of the original question: "you will see in the attached image what you on your own site display beneath the text area field I am typing in right now. This explains to users exactly which tags are allowed. So are they the full list of allowed tags, or can users use other tags, too (e.g. anchor tags, ordered lists, image tags, etc)...?

Very best wishes, and thanks again,
Andrew.

#563318

So with that in mind, if I use this code below then the scenario I desire should work, and the tags entered by the user in the CRED textarea field would be styled in the live post according to my CSS, yes?
You must echo types_render_field(), then the tags will be included in the page source.

So are they the full list of allowed tags, or can users use other tags, too (e.g. anchor tags, ordered lists, image tags, etc)...?
Our forum is a special case, and only the listed tags are fully supported. I often use blockquote as well, but the listed ones just to be on the safe side. On your own site, any HTML tag other than script will be saved in the database. Script tags will be stripped out, and the contents between the script tags will be written out in the page source.

#563356

Hi Christian,

Okay, so to confirm the correct code I need to use is as follows (just for my record when referring back here:

echo types_render_field( "my-textarea", array( "output" => "raw" ) );

And thanks for confirming that all HTML tags aside from the script tag will work. That is excellent news.

Very best wishes,
Andrew.

#563372

Yes this example looks correct now. Good luck!

#563377

Thank you! I'll give it a whirl asap.

#563992

Okay let me know when you are ready. I have marked this ticket as pending an update from you.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.