FormContainer not working, multiple issues...

Withe the default page/form I can use the FormContainer to place the form within the corresponding html page for the form, however, if in that form I try to display another form that has it's own HTML page and try to specify the FormContainer, it get's ignored.

So if I have a TForm1 and a TForm2 with TForm1 being the primary. If I do the following...

   newform := TForm2.CreateNew(@AfterCreate);

The FormContainer is ignored.

If I do 

   newform := TForm2.CreateNew('form2container',@AfterCreate);

The form2container id must be in the Form1 html file and not the Form2 html file.
If I close newform (after doing it this way) with modalresult:=mrOk or any other proper response, it appears to remove the element containing the form2container id as it no longer appears where it is supposed to be and appears over top of Form1 (when created a second time) and when closed it again, Form1 no longer shows.(and the app basically disappears from view).

Right now I am trying to resort to not using the html pages, since I can't properly place the forms within them (other then the primary), but would really like to see this working properly.

If I am missing something, or have any suggestions, please let me know.

It looks like you are confusing form hosting and the form container specifier per form for the form in the associated HTML file.

The demos under Demo\Basics\Multiform and Demo\Basic\FormHosting should make this difference clear.

In a nutshell, using the TWebForm.FormContainer property will make a form appear within a HTML element with ID = FormContainer for the associated form template HTML file.

When you use form hosting, i.e. use the CreateNew() overload with a possible specifier for an element in which the new created form will be hosted, this will refer to a HTML element in the form from in which the hosted form is shown, i.e. either a HTML element already present in the HTML template of the hosting form or a HTML created by the hosting form. The hosted form will not use its own FormContainer then but will be hosted in the HTML element designated by the hosting form.

Actual it is two issues. 

The FormContainer only works with the Primary form any attempt to use it with any other forms fails (is ignored).

Second issue is with the CreateNew() works fine the first time when specifying the container id for the first create, but if the created form is closed and created again, it doesn't work properly as it doesn't create in the right location, and if you close the form again, the primary form won't display leaving you with a blank page and no ability to use the application.

I fail to see what you mean or see a problem.

1) When WebForm.FormContainer is used, this specifies the HTML element ID where to insert the form in the HTML template associated with the form. I.e. it refers to a HTML element for form1 in the HTML template associated with form1 and for form2, the form2.FormContainer is a HTML element in the HTML template associated with form2.

2) When using CreateNew(ElementID), this inserts the form in a HTML element in the form from where the subform is created. The FormHosting demo shows this. If this is a HTML DIV, the form will be created and form controls will be shown in this DIV. When the form is closed, this DIV will be empty but still exist.  You can see this in the FormHosting demo where the form contained in the panel can be created & closed multiple times after each other.

These 2 concepts and the way it works is by design.
If somehow you still encounter an issue with how this is designed, please provide a sample source project and detailed steps with which we can reproduce this here. Please send this by email.

Correct, but the form2.FormContainer is ignored when displaying form2. I have tried it a number of times, but it does not attach to the HTML element specified in the form2.html page. The only page it works with is the form1 (or the first form to display when the application starts). Any future form creation with any other form, the corresponding FormContainer is ignored for that form.

..then again...

I just discovered that part of this issue "appears" to be with the ElementPosition. If set to absolute, it is absolute to the main page (not it's own page or form as I assumed it to be). Changing this to Relative (or putting everything in a panel and setting it's ElementPosition to relative) may resolve this, as it appears now.


Actually using TWebForm.CreateNew(AElementID: string; AProc: TFormCreatedProc); where you can specify the ElementID the form is to be attached/appended too. The first time it creates, it attaches and displays properly. If that form is closed, then created again, it no longer attaches to where it was supposed too (as if the DIV or element was removed when the form was closed previously). Then when the new form is closed again, the primary app is no longer visible.

In the sample you can download below, click the "Click Me" button, then click the "close me" button, then click the "Click Me" button again and click the "Close Me" button again and see what happens.

This helped to see & understand the issue.
We are working to have this addressed for the next update.