Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to peoperly show text content that contains html tags in easyadmin show page? #3687

Closed
0x48415a484952 opened this issue Aug 20, 2020 · 9 comments

Comments

@0x48415a484952
Copy link

i have used ckeditor in easyAdmin3 now whenever i want to display the content it will display it like below
image
how to solve this issue?

@jmsche
Copy link
Contributor

jmsche commented Aug 28, 2020

Hi, I don't know how you use CKEditor exactly, but in my project I created a CKEditorField and set the template name to crud/field/text_editor.

@seb-jean
Copy link
Contributor

@AhmadzadehHazhir, can you show us your code to help you?

@Annegren
Copy link

Annegren commented Nov 12, 2021

@AhmadzadehHazhir hi, have you found the solution ? because I have the same issue

@parijke
Copy link
Contributor

parijke commented Nov 12, 2021

I have made a custom template for it
in templates/bundles/EasyAdminBundle/crud/field/text_editor.html.twig

{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
{# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #}
{# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #}
<!-- Own template in templates/bundles/EasyAdminBundle-->
{% if ea.crud.currentAction == 'detail' %}
    {{ field.value|raw }}
{% else %}
    {% set html_id = 'ea-text-editor-' ~ field.uniqueId %}
    <a href="#" data-bs-toggle="modal" data-bs-target="#{{ html_id }}">
        <i class="far fa-file-alt"></i> {{ 'field.text_editor.view_content'|trans([], domain = 'EasyAdminBundle') }}
    </a>

    <div class="modal fade" id="{{ html_id }}" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">{{ field.label }}</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"
                            aria-label="{{ 'action.close'|trans([], domain = 'EasyAdminBundle') }}">
                    </button>
                </div>
                <div class="modal-body">
                    {{ field.formattedValue|nl2br }}
                </div>
            </div>
        </div>
    </div>
{% endif %}

@Annegren
Copy link

is there any configuration to do in the crudcontroller instead ?

@parijke
Copy link
Contributor

parijke commented Nov 12, 2021 via email

@parijke
Copy link
Contributor

parijke commented Nov 13, 2021

Like this:

            yield CollectionField::new('insurancePolicies')
                ->setTemplatePath('customer-policies.html.twig')
                ->onlyOnDetail();

@Annegren
Copy link

great many thanks :)

@javiereguiluz
Copy link
Collaborator

Thanks for this proposal. I'm closing this issue in favor of #6675, which tries to improve this. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants