1

I have a custom field with data type 'Note' and field type 'TextArea'. When I insert a value using the CiviCRM interface, I can insert text via an editor, and bold text gets displayed as bold, italic etc.

Now I want to put html in this same field using the API, but the problem is that any html characters are converted to html entities when inserted.

  $params = array(
  'contact_id' => $contact_id,
  'entity_id' => $contact_id,
  'custom_' . $content_field_id => '<div class="note_content">' . implode('</div><div class="note_content">', $data['note_content']) . '</div>',
);
$create_note_result = $spcivi->api('CustomValue', 'create', $params);

html send via api:

<div class="note_content"><strong>Vette</strong> tekst is toegestaan!</div><div class="note_content"><em>Shuine</em> ook!</div>

result content in field:

&lt;div class="note_content"&gt;&lt;strong&gt;Vette&lt;/strong&gt; tekst is toegestaan!&lt;/div&gt;&lt;div class="note_content"&gt;&lt;em&gt;Shuine&lt;/em&gt; ook!&lt;/div&gt;

Is there a way to insert html without the html characters being converted to html entities? Using the field type TextArea becomes quite useless when not html can be inserted.

1

Have you tried any of the following before submitting the TextArea?

  1. Highlight the code portion and Ctrl + K or Command K

  2. Indent the code lines 4 spaces

  3. Use backtics ' your html '

  4. Use code tag <code>your html</code>

1

This appears to be unsupported in the API, which encodes all HTML values. I've created a JIRA issue to request this functionality: https://issues.civicrm.org/jira/browse/CRM-21572

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.