Open Closed

[BUG] ABP Suite can't generate customized Modals completly #9773


User avatar
0
rafael.gonzales created

Hello!

I have issues with **CUSTOMIZED **templates in a Module in ABP Suite. If I try to generate a customized Frontend.Mvc.Page.CreateModal.cshtml.txt or Frontend.Mvc.Page.EditModal.cshtml.txt it will generate the modal until the end of the properties only and It will skip any other modification after that

This is the original template from ABP Suite

@page
@using Microsoft.AspNetCore.Mvc.Localization
@using %%project-name%%.Localization
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
@using %%project-name-with-ms%%.%%web-namespace%%.Pages.%%<if:IsModule>%%%%only-project-name%%.%%</if:IsModule>%%%%entity-name-plural%%
%%<if:IsNotMicroserviceNoLayerProject>%% using %%project-name%%%%<if:ApplicationContractsNotExists>%%%%.AppServices%%</if:ApplicationContractsNotExists>%%.%%entity-namespace%%; %%</if:IsNotMicroserviceNoLayerProject>%%
@using System.Globalization
@inject IHtmlLocalizer<%%only-project-name%%Resource> L
@model CreateModalModel
@{
    Layout = null;
}


<form data-ajaxForm="true" asp-page="/%%module-name-slash-postfix%%%%entity-name-plural%%/CreateModal" autocomplete="off">
    <abp-modal id="%%entity-name%%CreateModal">
        <abp-modal-header title="@L["New%%entity-name%%"].Value"></abp-modal-header>

        <abp-modal-body>
@*//<suite-custom-code-block-1>*@
@*//</suite-custom-code-block-1>*@
             <abp-tabs>
                %%main-entity-tab%%
                %%navigation-connection-lookup-tabs%%
@*//<suite-custom-code-block-2>*@
@*//</suite-custom-code-block-2>*@
            </abp-tabs>
@*//<suite-custom-code-block-3>*@
@*//</suite-custom-code-block-3>*@
        </abp-modal-body>

        <abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)">
@*//<suite-custom-code-block-4>*@
@*//</suite-custom-code-block-4>*@
        </abp-modal-footer>
    </abp-modal>
</form>

If you add for example a <div> before the <abp-modal> tag. It will generate code ONLY until the end of %%navigation-connection-lookup-tabs%%. It will ignore everything else after that. It only works if it's the default template.

Please, this is critical. It breaks completly Module code generation in ABP Suite.


10 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent

    To ensure your custom code is preserved and correctly generated in ABP Suite's templates, you must use the special custom code block placeholders provided by ABP Suite. When customizing templates like Frontend.Mvc.Page.CreateModal.cshtml.txt or Frontend.Mvc.Page.EditModal.cshtml.txt, any code you want to persist and regenerate must be placed between these placeholders:

    <!--<suite-custom-code-block-0>-->
    <!--</suite-custom-code-block-0>-->
    

    For example, to add a <div> before the <abp-modal> tag and ensure it is not lost during code generation, wrap your custom code like this:

    <!--<suite-custom-code-block-0>-->
    <div>Your custom content here</div>
    <!--</suite-custom-code-block-0>-->
    <abp-modal id="...">
        ...
    </abp-modal>
    

    ABP Suite will preserve and move any code inside these blocks during regeneration. If you add custom code outside of these placeholders, it may be ignored or overwritten by the generator, especially after the property section or template variables.

    • Use unique numbers for each custom block if you need multiple customizations.
    • The order and numbering of placeholders do not need to be sequential.

    For more details, see the official documentation below.

    Sources:

    • https://abp.io/docs/latest/suite/customizing-the-generated-code
    • https://abp.io/support/questions/4328

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    rafael.gonzales created

    The AI answer is not correct. It's not about preserving code when regenerate it but when the FIRST generation happens from the template as the source.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi, as far as I understand, you said that when customizing an existing template (like Frontend.Mvc.Page.CreateModal.cshtml.txt, for example), it's not applying it correctly. So, to test it out, I've created a new layered MVC application and customized the related template, and the changes are there as expected:

    Customized the template from the /Templates page (and simply added a div with a paragraph):

    This customization should add a file into your .suite folder:

    Here is the generated code:


    Did I understand you correctly? Can you check that your template has a customized badge on the templates page or not?

  • User Avatar
    0
    rafael.gonzales created

    Hello EngincanV

    Yes, I have the templates as customized

    I modified the template (I added a Hello world inside)

    But it produces the following code

    • There is no "@" in the using
    • After the last property is added then it ignores completly everything
    • It doesn't add those comments for SUIT custom code block

    Notes: -I put the "modules" folder at the same level of "src" -The project was completly created with ABP Studio, the main project and all the modules -I entered in ABP Suite using the "abp suite" command in terminal in Windows 11.

  • User Avatar
    0
    rafael.gonzales created

    I created a new ABP Demo Solutio with ABP Studio and replicate the same with the modules but It happens exactly the same issues but a couple of things added.

    Not sure why but when the entity is created. I get redirected to this website https://abp.io/docs/latest/framework/infrastructure/blob-storing/database?_redirected=B8ABF606AA1BDF5C629883DF1061649A

    The DbContextModelCreatingExtensions.cs is also created without usings and it generates conflicts with Rider IDE to match the encoding

  • User Avatar
    0
    rafael.gonzales created

    Not sure if it's related but I see this in the developer tools of the browser when running ABP Suite

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    [rafael.gonzales] said: Not sure if it's related but I see this in the developer tools of the browser when running ABP Suite

    Hi, it's not related to that, but this is also something we need to fix. I'll add to the bundle with 9.3.2.

    For your main problem, I'll try to reproduce it today, and write back asap. If I'm not able to reproduce it, i may ask your need to send your project via email.

    Regards.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi @rafael.gonzales, I'm unable to reproduce the problem. By any chance, can you please send your project via email to support@abp.io (with ticket number)?

  • User Avatar
    0
    rafael.gonzales created

    Hello @EngincanV. Sure. I will send you the demo project. Is it possible to calendar a meeting and show you the issue directly?

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    [rafael.gonzales] said: Hello @EngincanV.
    Sure. I will send you the demo project. Is it possible to calendar a meeting and show you the issue directly?

    Hi @rafael.gonzales,

    Thanks. Please send me the demo project first so I can check and try to reproduce the issue. If I’m not able to reproduce it on my side, then we can schedule a meeting to review it together.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on September 05, 2025, 09:28