TWebForm Use Multiple HTML Templates


Is this possible?

The reason for this is that I need to open the same form twice and need to avoid duplicate ID's.



That isn't possible right now.
How do you see this work in detail?

The only way I can think of would be to make a descendant and allocate new ids. Not very elegant though.

Not sure. Let me play around with it for now. My form has no components so I'm just going to try putting a div in the body of the form and just replace its innerHTML.

1 Like

What else is in the form?

There are alternatives to using the innerHTML property. Elements can be added individually (programmatically) as well, if you have a particular structure you're trying to build and want to do it in a more involved way. Here's an example where this was done to build up the "lights" interface in the Catheedral/Home Assistant project - a fairly complex bit of code to add buttons with all the related classes and event listeners - that gets regenerated whenever this part of the app is used (see the section on Displaying Lights).

If it's just a large block of HTML already configured with id's and the rest of it, and it doesn't need to change, then innerHTML is probably the best way to go.

If you will only ever have two copies of the form open at the same time, another idea is to just create a second copy of the form with a second set of id's?

The only way I've been able to get this to work is to use an inherited form and modify the HTML Template. Far from ideal but it works!

1 Like