Expand my Community achievements bar.

lock code for fragments

Avatar

Level 1

I'm using AEM Forms and I use a lot of fragments. Sometimes the fragments have some code, for example the company header that can change depending on the brand code. One thing I noticed is that  when you use those fragments on a form, if you click on that fragment, the code appears to not be editable (grayed-out), and if you try to type something it won't allow you, but, if you press some keys like tab or enter or space bar, the code will start to be editable. And you might even not edit anything (maybe you just added an enter accidentally), but the entire fragment code will now be in the form's XML source code. And once this code is in the form's xml code, the fragment kinda loses it's point (in the form that you accidentally "edited"), because from now on, any code that you add to your fragment will be ignored, because the program will actually use the code that is in the forms xml source. So my question is if there would be any way to protect myself from this? 

 

Here is an example.
The fragment has some code and it's locked initially and nothing on the xml source of the form:

(it even shows this message that I highlighted)

rodrigoJunqueira_0-1690301680511.png

rodrigoJunqueira_1-1690301769004.png

 

 

Now if I, for example, accidentally click on the tab button. In this picture I already pressed tab, and the editor window still appears to be grayed-out:

rodrigoJunqueira_2-1690301995430.png

 

But on the xml source file, it added all the fragment code:

rodrigoJunqueira_3-1690302068152.png

 

The only ways I found to fix this, is either delete the code from the xml file or to remove the fragment and add it again.
Any suggestions?

 

Thanks!


Also a note: If the fragment code is in the root of the fragment, the code in the form it won't even be grayed-out, so it is even easier to accidentally edit the code. If you edit it, it does the same thing (adds the code to the xml source).

 

 

0 Replies