Jahan Ahmed Abbasi
Jahan Ahmed Abbasi

Reputation: 89

CKEditor removes custom <span> with a class

I have a form on my website where admin can edit the contract which is shown on the registration form. there are few fields in a form which are dynamic meaning on the first page of registration form there is first name, last name of the person who is registering. I want to get his names and replace with template_field_name as defined in contract. Here is a sample of what i am trying to do

<p>contactor: <span class="template_name">template_name</span></p>

later when the page renders on registration form i will look for template_name class and replace the text with jquery to the value i am getting from first name and last name field from the first page of registration form. but when admin make some changes later to contract it just eliminate the span tag with class name

<p>contactor:template_name</p>

and outputs the template_name as above. I am tired to this issue and tried so many times to solve this.

any help would be appreciated.

Upvotes: 1

Views: 1635

Answers (1)

user6100520
user6100520

Reputation:

Probably, your problem in Advanced Content Filtering (ACF) of CKEditor.

Try to set configuration option to allow everything:

config.allowedContent = true;

See if it's working for you. If it is, replace config.allowedContent with:

config.extraAllowedContent = 'span(template_name)';

which will allow the class template_name for the span tag.

More information about ACF here - https://docs.ckeditor.com/ckeditor4/docs/#!/guide/dev_acf

To add multiply allowed classes you can specify them separated by comma:

config.extraAllowedContent = 'span(template_name,another_class,one_more_class)';

Or you can allow every class for span tag, like this:

config.extraAllowedContent = 'span(*)';

If fields represent by different tags - you need separate them by space

config.extraAllowedContent = 'span(template_name) p(another_template_name)';

Upvotes: 1

Related Questions