Insert HTML code in WYSIWYG field

3 posts by 3 authors in: Forums > CMS Builder
Last Post: Monday at 11:35pm   (RSS)

Hello Andreas,

WYSIWYG fields are typically piped through TinyMCE and any HTML/Code you put through it is restructured/reformatted to be proper HTML structure and not executed on the server side (this includes stripping out unrecognized tags such as PHP tags).

There are ways to get the editor to not filter out any PHP code (for instance to save it in the database) but it is advised to be very careful with this as you can easily introduce a security risk. If anyone is able to put PHP code into one of those fields and it is executed by your server, that would be bad.

Another option would be to have your code run PHP first and then put its output into the editor when it initializes. It all really depends on what you are trying to accomplish. :)

Tim Hurd
Senior Web Programmer
Interactivetools.com

Hi Andreas, 

Some additional thoughts on this. 

The "default value" content in the field editor is only used when you create new records, and when creating a new record, the $RECORD values will not exist yet.

If you're passing date_of_visit in the create record link, maybe something like this could work?

<?php echo htmlencode($_REQUEST['date_of_visit'] ?? 'Ημερομηνία δεν είναι διαθέσιμη'); ?>

The ?? means "if the previous value isn't defined, use the next value".

Let me know if that helps, or more details about what you're trying to do.

Dave Edis - Senior Developer
interactivetools.com