2

I have a description field with a CK editor enabled. And when I get the data from it as node->get('fieldname')->getString() it outputs the content as below.

The contents that I have entered in the Ck editor

, basic_html

I can resolve this in the twig file by getting this as {{fieldname| raw}}. But I need to get this in a php file. How do I get the value without that , basic html part?

0

1 Answer 1

3

How do I get the value without that , basic html part?

$node->field_name->value; should do the trick.


I can resolve this in the twig file by getting this as {{fieldname|raw}}.

Using | raw filter in twig is bad security practice, see How do I get the raw field value in a twig template? for a safe solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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