Forums

Multiple forms in same page

PicoPaco 12 Oct, 2011
Hi,

I am trying to create a form form multiple forms. I have created one form that shows two other forms (Show Form) in the same page, but it doesn't send the data to the next form.

I think the problem is that the two forms isn't in the same form tag. I have put "data to session" in the "main form" (the form where the other two is included) and in the next form (after submit) I have put "session to data".

Anyone got a solution for this?
GreyHead 12 Oct, 2011
Hi PicoPaco,

You need to make sure that the two DB <> Session actions use the same Session Key. It defaults to the form name which will be different.

Bob
PicoPaco 12 Oct, 2011
Hi Bob,

I have not yet done any db-connections. Can I set the "Data To Session's" Session Key and Session Namespace to the same as the ones in Session To Data? In which of the forms should I put "Session To Data"?

Here is how I try to build the forms:

I have four forms:
* Contact info
* Address info
* User
* Confirm

In User I put two "Show Form", Contact info and Address info.

After submitting User the Confirm form is shown. The Confirm form shows the data from User (contact info and address info) and have a couple of input fields for additional information.

Thanks
/Markus
GreyHead 12 Oct, 2011
Hi PicoPaco,

Too much of a rush this morning . . . I meant the 'Data to Session' and 'Session to Data' actions. You need to save the data to the session the On Submit event of the first form and get it back from the session in the On Load event of the second form.

Bob
PicoPaco 12 Oct, 2011
That's what I am trying to do. Here is what I did:

* Contact info - On Submit -> 'Data to session'
* Address info - On Submit -> 'Data to session'
* User - On Load -> 'Show Form' (two, one for contact info, one for address info). Also holds the submit button.
* Confirm - On Load -> 'Session to data'. I also have a custom code: <?php echo $form->data['telephone']; ?>

In Contact info I have a field named 'telephone'.
GreyHead 12 Oct, 2011
Hi PicoPaco,

And which bit isn't working?

Bob
PicoPaco 12 Oct, 2011
It won't display any data πŸ˜‘

<?php echo $form->data['telephone']; ?>
Doesn't seem to fetch the data from the previous form.
GreyHead 12 Oct, 2011
Hi PicoPaco ,

Do you have the Session Keys matched up?

By all means email or PM me the site URL and a SuperAdmin login and I'll take a quick look.

Bob
PicoPaco 13 Oct, 2011
You got a PM, thanks.
PicoPaco 17 Oct, 2011
I have the same session key, but I can't get this to work.

I am trying to create one 'mother form' that contains two 'child forms'. I also have tried to put the submit button in a new form. Should I have 'data to session' in all my forms, or just the mother form? Should every child forms have form tags and should submit action be on submit or self?

A lot of questions, but I really need this to work πŸ™‚
PicoPaco 19 Oct, 2011
I believe it doesn't work because the child-forms isn't in the same <form> tag as the submit button. Is there any way to do this anyway?
Max_admin 20 Oct, 2011
Hi PicoPaco,

Please tell me what you need to do in general because maybe your implementation is wrong or not even doable, tell me the idea and I will try to tell you the best way to implement it.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 20 Oct, 2011
Hi PicoPaco,

You can’t nest <form> tags i.e. <form. . .>. . .<form . . .> . . .</form></form> is not allowed.

There is an option to turn off the Form tags on the form General tab; I guess that would allow you to put one form inside another by turning off the tags for the inside form. I'm not clear why you would want to though.

Bob
PicoPaco 21 Oct, 2011
Hi,

Max, I am going to produce a lot of forms. All of these forms will have some general inputs i.e name and contact information, but also inputs depending on witch forms you've chosen. Because of this I'd like to separate the forms, so that the general information is on one chronoform and the form specific inputs is in other chronoforms.

Bob, I have succeeded this by not including form tags on each form and instead use custom code with the form tag in the 'mother'-form. I don't know if this is a good solution.


Thanks

Markus
GreyHead 21 Oct, 2011
Hi Markus,

I've never doen it but that should work OK.

With complex forms I prefer to build one form and then use PHP to control which parts are displayed. You could, for example, use conditional include statements to add in particular chunks of HTML.

One action that is missing from ChronoForms v4 at present is a simple conditional test: if this result do this, else do that. You can workaround with some of the sub-events but it's not at neat.

Bob
PicoPaco 21 Oct, 2011
Hi Bob,
Yeah, the idea to build the forms in php have striked me. Should I build it without the wizard then? I like all the benefits with the wizard i.e db connections, session handeling, validation and so on. Could I still use this some how? Is it possible to use php includ with chronoforms? To include a form in another form with php in chronoform?

Thank you

Markus
GreyHead 22 Oct, 2011
Hi Markus,

In ChronoForms v4 the Form HTML and the Wizard are separate. You can hand-code your Form HTML and still use all the events and actions.

To include Form HTML from another file put this in the HTML code box
<?php
include (JPATH_SITE.DS.'components'.DS.'com_chronocontact'.DS.'includes'.DS.'form_name'.DS.'formhtml.php');
?>

Bob
PicoPaco 23 Oct, 2011
Thanks Bob, this sounds like the way to go. Should the file I include be a external php-file? Where should I put it? Where it says 'form_name' I guess it is the name of the chronoform? What should I put in formhtml.php then?


Thanks

Markus
GreyHead 23 Oct, 2011
Hi PicoPaco,

You can put the file anywhere in the site. Personally I use components/com_chronoforms/includes folder but I have clients who prefer to put them in the template html folder (where template over-rides live), or into a 'forms' folder in the site root.

Bob
This topic is locked and no more replies can be posted.