Buy Now
Sign in

How to show the data of a form inside another?

PePa , March 25 2013, 10:42
P
PePa 6
March 25 2013, 10:42 #308730
Dear Chronoteam,
i am using your free version of chronoforms V4 and i have to say this is far the best form-creator i have tryed out for joomla in all these years! Thanks for this great tool. I was already posting a review to Extension-Directory and i am even thinking of buying a Pro-Version eventually.
Anyway today i do have a big problem in setting up and using CF4 correctly (i guess).

Here is my issue:
I was setting up a multipage-form which is supposed to act as a survey, asking (registered) users about 10 questions, storing the records of the answers made into newly created a db-field which i linked to the form. Up to this point the survey itself works perfectly, if a user answeres all questions and submits, the data get stored in the db. So far so good.

Now i wanted to display ALL of these record entries, the "results of the survey(s)" to other (non-registered) users in a nicely formatted page-view.
So i created another (empty) 2. form with yet no fields(!), using the "DB Multi Record Loader" setting up the name of the db-field where the data of my first form gets stored in.
Inside the fields-column i was entering all the form-fieldnames i used in my first form as well as in the "Display-fields"-column of the "Data-Displayer"-Tab in comma-separated lists.
In the "On Records found" field i added a "Handly arrays" as well as a "Show Html"-event.
In the "On empty result" field is has just a custom code event, notifying me "Empty Table !!! No Data !!". After the "DB Multi Record Loader" i added a Stopper-Event to quit the form from running.

I was already also following the instructions of the "CFV4_db_multi_record_loader.pdf" of your tutorials, setting up another "CustomCode-Field" containing all the fields i was using in my first form, in the following syntax:

<?php
foreach($form->data['j25_choronoforms_data_mydata_basefield'];
?>
<tr>
<td>Name: <?php echo $detail['name']; ?></td>
... and so on ...
</tr>
<?php endforeach; ?>
</table>

So now my problem: everytime i am loading the 2. form that is supposed to show my data from db there is none! But the data IS stored in db...
I was already setting up a debugger, THERE it shows my data-records from db, but it isnt displayed inside my page(form) so:

What am i doing wrong???
Why isnt my data showing up?
How can i exactly set up Chormoforms to just display (non-edit) the record-entires of my first form inside a page?

I am really SORRY to bother with such easy stuff maybe, but i am busting my head off since hours with no result

Greatly apprechiate your quick help, thanks a lot in advance,
Peter

--
Added to Post:

Hello, somebody here??
It seems no ideas come along to my post? Any ideas? I am stuck ...
Could someone help me please and point me at least in the right direction?
Thank you !
GreyHead 64
March 28 2013, 18:25 #308875
Hi PePa,

This PHP is broken:
<?php
foreach($form->data['j25_choronoforms_data_mydata_basefield'];
?>
I think you intended:
<?php
foreach($form->data['j25_choronoforms_data_mydata_basefield'] as $detail ) :
?>

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
R
rkamouni 8
June 01 2013, 10:15 #311933
I created a form with two pages.
I want the result of the first page stored in the database. To allow the user to edit this result and to continue later filling the form at the second page

To do this, I added the action "Save DB" in the event "On Submit" and another action "DB Save" in the event "On pagetwo".

Is this is the right way to do?

For a user who will fill the two pages of the form at one go, we end up with two records
Attachments
Screen Shot 2013-05-31 at 15.17.31.png
Screen Shot 2013-05-31 at 15.17.31.png
(157.53 KiB)
1419 Downloads/Views
Screen Shot 2013-05-31 at 15.18.29.png
Screen Shot 2013-05-31 at 15.18.29.png
(180.56 KiB)
1385 Downloads/Views
GreyHead 64
June 03 2013, 08:17 #311973
Hi rkamouni,

Basically I think that is OK except that the second DB Save needs to be on the Submit event for page two, not the on load event (otherwise there is no new data to save). You also need to make sure that the record id is carried through so that the same record is updated.

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
R
rkamouni 8
June 03 2013, 12:05 #311983
Hi Bob,
Thank you for your reply. However, I need more explanation:
- Should I add a new event that i call "On submit2 " (for example) in which I'll add "DB save". If the answer is yes, should I add something else to this event?
-how should I do so that the same record is updated (using record ID)
Attachments
Screen Shot 2013-06-03 at 12.30.25.png
Screen Shot 2013-06-03 at 12.30.25.png
(151.19 KiB)
1394 Downloads/Views
GreyHead 64
June 03 2013, 14:03 #311988
Hi rkamouni,

1) Yes; and you should add whatever other actions you want to run when the second form is submitted.

2) Usually the easiest way is to add a hidden input to your form with the name 'cf_id' (or the name of the primary key of your record if it is different). You'll need to get the value from the results that ChronoForms adds to the $form->data array after the first DB Save. You can use a Debugger action to see exactly what this is called.

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
R
rkamouni 8
June 05 2013, 08:20 #312077
Hi Bob,

What do you mean by second form?

Here is my actual configuration:

listdata.png

userdetails.png

My goal is to create a form with two pages.

Once the user has responded to the questionnaire on the first page, I want the data to be stored in the database. Thus, the user can load the data (of the first page) and continues to respond to the questionnaire on the second page.
Attachments
userdetails.png
userdetails.png
(247.11 KiB)
1371 Downloads/Views
listdata.png
listdata.png
(224.52 KiB)
1364 Downloads/Views
GreyHead 64
June 06 2013, 09:40 #312107
Hi rkamouni,

Sorry, the thread is titled "How to show the data of a form inside another?" and I read that.

The same applies with a multi-page form, add the DB Save actions to the Submit actions of each page.

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
R
rkamouni 8
June 06 2013, 13:07 #312120
Hi Bob,

Great, this was my first idea.

For a user who will fill only the first page of the form and exit. The procedure (as you suggested) works well.

But for a user who will fill the two pages (at once), the record is duplicated.
Indeed, by clicking on "nextpage", a first record is made. A second one is performed when the user clicks "Submit".

Have you any idea how to prevent this?
Attachments
Screen Shot 2013-06-06 at 14.46.54.png
Screen Shot 2013-06-06 at 14.46.54.png
(127.73 KiB)
1333 Downloads/Views
GreyHead 64
June 06 2013, 13:19 #312121
Hi rkamouni,

You need to keep the cf_id (or the primary key name if it is different) of the created record in the form data so that the same record is updated. Please check the FAQ for more info on this.

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
R
rkamouni 8
June 07 2013, 09:48 #312152
Hi Bob,


this solution does not seem to work for me. I add to my form "hidden box" that I renamed "cf_id".

Here's what I want, otherwise described:
Is it possible when you have a 10 page "Multi Page" to submit after page 5?
GreyHead 64
June 07 2013, 11:56 #312154
Hi rkamouni,

a) It works if you set it up correctly. But it does depend on the column names in your form. There is a FAQ with some more information.

b) Yes.

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much