Jump to content

Recommended Posts

Posted

I have a Table field that I am using for some spam filtering. I have one field in the table set as a Text field. If I enter <a href=" and save it becomes blank regardless of any text formatters applied.

It's weird because if I do the same with a Text field that is not part of a Table field it works fine. And within the Table field if I change it from Text to Textarea, it works.

Any ideas why?

Thanks.

Posted

Unfortunately I believe this is hardcoded behaviour (see _sanitizeValue() in FieldtypeTable.module).

As you noticed, it doesn’t strip tags from textareas, so maybe switch to that?

It should be quick work to add this as a per-column option like maxLength. Perhaps worth suggesting it to Ryan in the ProFields forum?

  • Like 1
Posted

Thanks for confirming.

Yes, I am currently using a Textarea rows="1" and removing line returns on save so it effectively does the same thing.

  • Like 1
Posted

If you want to modify the Module you could replace the original switch case in FieldtypeTable.module with this:

case 'text':
	$maxLength = empty($col['settings']['maxLength']) ? 2048 : (int) $col['settings']['maxLength'];
    $stripTags = empty($col['settings']['stripTags']) ? true : ($col['settings']['stripTags'] === 'false' ? false : true);
	$v = strlen("$v") ? $sanitizer->text($v, array('maxLength' => $maxLength, 'stripTags' => $stripTags)) : null;
	break;

That will allow you to specify stripTags=false on text colums.

  • Like 1

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
  • Recently Browsing   0 members

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