PDA

View Full Version : use one form for multiple components



optibase
11 Jan 2011, 6:08 AM
Hi
Is it possible to use one basicForm for multiple components?
In other words.. i need to use one server call to load data into a formpanel (formPanel1.load()). I also need to use some fields in this form (not used by formPanel1) in a window that holds formPanel2.

is doing somthing like this make sence
formPanel2.form = formPanel1.getForm();

thanks alot

Condor
11 Jan 2011, 6:18 AM
No, you can't.

Two options:
1. Create a single FormPanel that holds 2 normal panels with layout:'form'.
2. Load the first FormPanel and in the success handler of the load() call, call the setValues of the second form with action.result.

optibase
11 Jan 2011, 7:31 AM
No, you can't.

Two options:
1. Create a single FormPanel that holds 2 normal panels with layout:'form'.
2. Load the first FormPanel and in the success handler of the load() call, call the setValues of the second form with action.result.


thanks Condor
My first formpanel is inside a layout , my 2nd formpanel is inside a ext.win outside any layout and it is opened via a click on the first panel. so to my understanding, I can not use option 1 am I wrong?

using option 2, that is loading formpanel2 from formpanel1. will I still have validation working ( i mean thing like ranges etc) when using setValues?

thanks a lot,
you are allways a great help
:)

Condor
11 Jan 2011, 7:34 AM
Option 1 could still work (but I don't think you'll like it). You could make the entire application one single FormPanel and render the window to it.

Option 2 will do validations. The only problem with it is that you still have 2 forms, so you can't submit them together.

optibase
11 Jan 2011, 7:49 AM
Option 1 could still work (but I don't think you'll like it). You could make the entire application one single FormPanel and render the window to it.

Option 2 will do validations. The only problem with it is that you still have 2 forms, so you can't submit them together.

thanks,
I am not sure what you mean by " can't submit them together". assumnig I set the values from from1 to form2 as suggested, and that form2 is inside adialog that a user openes at some point and sets some values. when the user closes that dialog i can use setValues , from form2 back to form1.
this way form1 allways holds the correct values for 1 and 2, and upon submiting form1 i acualy submit both.
is that correct?

Thanks again

Condor
11 Jan 2011, 8:01 AM
Form1 will only submit values from form1 (but you could specify params with values from form2 - but this doesn't work if form2 has a fileupload field).
Also, the errors returned by the server are only applied to form1 (unless you also apply them to form2 in the failure handler).

optibase
11 Jan 2011, 8:10 AM
Form1 will only submit values from form1 (but you could specify params with values from form2 - but this doesn't work if form2 has a fileupload field).
Also, the errors returned by the server are only applied to form1 (unless you also apply them to form2 in the failure handler).

Yes ,that what I meant.. having form 1 hold params for both form 1 and 2 and submiting form1.
your comment on the file upload and server errors is what i was worried about and didnt know.
as far as I can see I will be OK without file upload and server errors.

thanks so much,
have great day.