Multi Record Display

mduda 21 Apr, 2015
In CFv4, we used the multi record loader. I then enabled the data displayer - and all the records for that specific user were displayed.

Re-creating the same form in CFv5 - and can't get the data to show. I have the form data for single records populating, but the second db read in the form isn't showing.

Multi-Read: Yes
Enable Model Id: Yes
Conditions:
<?php

return array( 'user_id' => $form->data('user_id'));

?>


What am I missing? I think the db read is setup properly? Is there somewhere in the displayer that I need to add the field for all the multi records?
mduda 21 Apr, 2015
I'm using CFv5 not v4, so this FAQ doesn't help.
GreyHead 21 Apr, 2015
HI mduda,

I'm not clear what the problem is here - the data appears to be showing up in the Debugger listing correctly?

Bob
mduda 21 Apr, 2015
It shows up in the debugger but how do I get it to actually display all of the records on the form? I have the first db read items showing up on the form. I'm able to display them thru the form using the field name in a text box. But the second db read I don't known how to get them to actually display on the form since this is s multi read.
GreyHead 21 Apr, 2015
Answer
Hi mduda,

In the Designer tab add a Custom Code element from the Advanced elements group. Add code like this:
<table>
  <thead> 
    <tr>
      <thead>Month</thead>
    </tr>
  <tbody>
<?php
foreach ( $form->data['vol'] as $v ) {
  echo "<tr><td>{$v['month']}</td></tr>";
}
?>
  </tbody>
</table>

Bob
mduda 22 Apr, 2015
PERFECT! That did the trick. Sent a beer your way 😀
dtws2008 07 Dec, 2015
Hello,
I have the same need.
I acted according Bob's directions (Added the relevant "foreach" code in a custom field at the designer tab)
I defined a DB read action with multi record.
Can't get it into work.
What am I doing wrong?
GreyHead 07 Dec, 2015
Hi dtws2008,

Please drag a Debugger action into the On Submit event, then submit the form and post the debug results here.

Please also post the Custom Code data you are using.

Bob
dtws2008 07 Dec, 2015
This done on load event. I need to get a list of titles (plus related information) for editing.

The custom code at the designer tab:
(At this stage I only want to see that it is principally works. Styling will come later.)
<?php
<p>
foreach ($form->data['title'] as $value) {
   echo "$value";
   }
</p>
?>

Debugger results:
Data Array
Array
(
    [option] => com_chronoforms5
    [chronoform] => Edit_a_Lesson
    [0] => Array
        (
            [id] => 1
            [userid] => 437
            [title] => test1
            [shortdescription] => sss
            [description] => <p>llllll</p>
            [picture] => 
            [link_extern] => 
            [max_price] => 10.00
            [currency] => USD
            [max_price_default_currency] => 0.00
            [auction_type] => 1
            [automatic] => 0
            [payment] => 0
            [start_date] => 2015-10-08
            [end_date] => 2015-11-25
            [closed_date] => 2015-10-21
            [published] => 1
            [close_offer] => 1
            [close_by_admin] => 0
            [hits] => 22
            [modified] => 0000-00-00 00:00:00
            [extended_counter] => 0
            [winner_id] => 438
            [cat] => 2
            [has_file] => 0
            [file_name] => 
            [job_deadline] => 23
            [show_bidder_nr] => 1
            [show_best_bid] => 1
            [NDA_file] => 
            [NDA] => 0
            [featured] => none
            [auction_nr] => 
            [cancel_reason] => 
            [googlex] => 
            [googley] => 
            [approved] => 1
        )

    [1] => Array
        (
            [id] => 2
            [userid] => 437
            [title] => test2
            [shortdescription] => sss
            [description] => <p>lllll</p>
            [picture] => 
            [link_extern] => 
            [max_price] => 10.00
            [currency] => USD
            [max_price_default_currency] => 0.00
            [auction_type] => 1
            [automatic] => 0
            [payment] => 0
            [start_date] => 2015-10-08
            [end_date] => 2015-11-26
            [closed_date] => 2015-10-09
            [published] => 1
            [close_offer] => 1
            [close_by_admin] => 0
            [hits] => 15
            [modified] => 0000-00-00 00:00:00
            [extended_counter] => 0
            [winner_id] => 438
            [cat] => 3
            [has_file] => 0
            [file_name] => 
            [job_deadline] => 10
            [show_bidder_nr] => 1
            [show_best_bid] => 1
            [NDA_file] => 
            [NDA] => 0
            [featured] => none
            [auction_nr] => 
            [cancel_reason] => 
            [googlex] => 
            [googley] => 
            [approved] => 1
        )

    [2] => Array
        (
            [id] => 3
            [userid] => 436
            [title] => test4
            [shortdescription] => sss
            [description] => <p>lll</p>
            [picture] => 
            [link_extern] => 
            [max_price] => 10.00
            [currency] => USD
            [max_price_default_currency] => 0.00
            [auction_type] => 1
            [automatic] => 0
            [payment] => 0
            [start_date] => 2015-10-08
            [end_date] => 2015-11-25
            [closed_date] => 0000-00-00
            [published] => 1
            [close_offer] => 0
            [close_by_admin] => 0
            [hits] => 7
            [modified] => 0000-00-00 00:00:00
            [extended_counter] => 0
            [winner_id] => 0
            [cat] => 6
            [has_file] => 0
            [file_name] => 
            [job_deadline] => 17
            [show_bidder_nr] => 1
            [show_best_bid] => 1
            [NDA_file] => 
            [NDA] => 0
            [featured] => none
            [auction_nr] => 
            [cancel_reason] => 
            [googlex] => 
            [googley] => 
            [approved] => 1
        )

    [3] => Array
        (
            [id] => 4
            [userid] => 439
            [title] => dogs tamming
            [shortdescription] => aaaa
            [description] => <p>aaaaaaaa</p>
            [picture] => 
            [link_extern] => 
            [max_price] => 1500.00
            [currency] => AUD
            [max_price_default_currency] => 0.00
            [auction_type] => 1
            [automatic] => 0
            [payment] => 0
            [start_date] => 2015-10-11
            [end_date] => 2015-11-26
            [closed_date] => 0000-00-00
            [published] => 0
            [close_offer] => 0
            [close_by_admin] => 0
            [hits] => 0
            [modified] => 0000-00-00 00:00:00
            [extended_counter] => 0
            [winner_id] => 0
            [cat] => 4
            [has_file] => 0
            [file_name] => 
            [job_deadline] => 20
            [show_bidder_nr] => 1
            [show_best_bid] => 1
            [NDA_file] => 
            [NDA] => 0
            [featured] => none
            [auction_nr] => 
            [cancel_reason] => 
            [googlex] => 32.799423087452205
            [googley] => 34.97114539146423
            [approved] => 1
        )

Debug Info
Array
(
    [12] => Array
        (
            [DB Read] => Array
                (
                    [Queries] => Array
                        (
                            [0] => SELECT `Data`.`id` AS `Data.id`, `Data`.`userid` AS `Data.userid`, `Data`.`title` AS `Data.title`, `Data`.`shortdescription` AS `Data.shortdescription`, `Data`.`description` AS `Data.description`, `Data`.`picture` AS `Data.picture`, `Data`.`link_extern` AS `Data.link_extern`, `Data`.`max_price` AS `Data.max_price`, `Data`.`currency` AS `Data.currency`, `Data`.`max_price_default_currency` AS `Data.max_price_default_currency`, `Data`.`auction_type` AS `Data.auction_type`, `Data`.`automatic` AS `Data.automatic`, `Data`.`payment` AS `Data.payment`, `Data`.`start_date` AS `Data.start_date`, `Data`.`end_date` AS `Data.end_date`, `Data`.`closed_date` AS `Data.closed_date`, `Data`.`published` AS `Data.published`, `Data`.`close_offer` AS `Data.close_offer`, `Data`.`close_by_admin` AS `Data.close_by_admin`, `Data`.`hits` AS `Data.hits`, `Data`.`modified` AS `Data.modified`, `Data`.`extended_counter` AS `Data.extended_counter`, `Data`.`winner_id` AS `Data.winner_id`, `Data`.`cat` AS `Data.cat`, `Data`.`has_file` AS `Data.has_file`, `Data`.`file_name` AS `Data.file_name`, `Data`.`job_deadline` AS `Data.job_deadline`, `Data`.`show_bidder_nr` AS `Data.show_bidder_nr`, `Data`.`show_best_bid` AS `Data.show_best_bid`, `Data`.`NDA_file` AS `Data.NDA_file`, `Data`.`NDA` AS `Data.NDA`, `Data`.`featured` AS `Data.featured`, `Data`.`auction_nr` AS `Data.auction_nr`, `Data`.`cancel_reason` AS `Data.cancel_reason`, `Data`.`googlex` AS `Data.googlex`, `Data`.`googley` AS `Data.googley`, `Data`.`approved` AS `Data.approved` FROM `pkzaq_rbid_auctions` AS `Data`
                        )

                )

        )

) 
GreyHead 07 Dec, 2015
Hi dtws2008,

There is something odd with the setup of the DB Read because the data you have there doesn't have an array name - see Mduda's earlier post where it is [vol]. I'm not clear why that is happening. Is there a Model ID set - it looks like Data from the query but then I don't see why the values for option and chronoform are in the same array :-(

And the PHP you are testing with is not the same as my example - title is one of the database columns, not the Model ID.

Bob
dtws2008 07 Dec, 2015
Thanks Bob,
The DB Read is minimal set. Only the basic, no Model ID.
I do get this in red in the debugger:
Errors
Array
(
)

With one record only, the form functions as expected.
Regarding the php, I tried several variations, nothing helped.
Any idea which course to take in exploring the problem?
dtws2008 07 Dec, 2015
Well, you were right! the DB Read was wrongly set.
The Model id was disabled and with null value.
I have changed this and it is ok now!
Thanks a lot!
dtws2008 08 Dec, 2015
Hello Bob,
Now that it works, I would like to achieve the following:
I have a one record form that displays a title and all its related data.
I want a dynamic list of forms. Each form displays a title and all its related data, for all the titles.
I removed the "foreach" clause from the design tab and put it in a custom action before the HTML render in the setup tab.

Here it is:
<?php

foreach ( $form->data['lesson_data'] as $v1 ) {
             foreach ($form->data['lesson_data'] as $v2){
             if ($v2['start_date'] == $v2['end_date']) {
    $v2['when_to_start']="1";
} 
elseif ($v2['job_deadline']=="7") {
    $v2['when_to_start']="2";
} else {
    $v2['when_to_start']="3";
}
$v2['what_is_your_budget']="1";
if ($v2['max_price']==0){
   $v2['what_is_your_budget']="2";} }             

}

?>


I have looked at the HTML render for a multi page and I see that I have to setup forms ahead for multi page.
I need a dynamic multi page form.
Is it possible?

Here is the debugger results:

Array
(
    [option] => com_chronoforms5
    [chronoform] => Edit_a_Lesson
    [lesson_data] => Array
        (
            [0] => Array
                (
                    [id] => 201
                    [userid] => 513
                    [title] => Learn history
                    [shortdescription] => History of 21'st century
                    [description] => History of 21'st century
                    [picture] => Picture namecome here
                    [link_extern] => External link comes here
                    [max_price] => 250.00
                    [currency] => AUD
                    [max_price_default_currency] => 250.00
                    [auction_type] => 1
                    [automatic] => 0
                    [payment] => 0
                    [start_date] => 2015-12-08
                    [end_date] => 2015-12-15
                    [closed_date] => 0000-00-00
                    [published] => 1
                    [close_offer] => 0
                    [close_by_admin] => 0
                    [hits] => 0
                    [modified] => 0000-00-00 00:00:00
                    [extended_counter] => 0
                    [winner_id] => 0
                    [cat] => 11
                    [has_file] => 0
                    [file_name] => 
                    [job_deadline] => 7
                    [show_bidder_nr] => 1
                    [show_best_bid] => 1
                    [NDA_file] => NDA file comes here
                    [NDA] => 0
                    [featured] => none
                    [auction_nr] => 
                    [cancel_reason] => 
                    [googlex] => 
                    [googley] => 
                    [approved] => 0
                )

            [1] => Array
                (
                    [id] => 202
                    [userid] => 513
                    [title] => Learn Math
                    [shortdescription] => Learn Infinitesimal calculus  
                    [description] => Learn Infinitesimal calculus  
                    [picture] => Picture namecome here
                    [link_extern] => External link comes here
                    [max_price] => 432.00
                    [currency] => AUD
                    [max_price_default_currency] => 432.00
                    [auction_type] => 1
                    [automatic] => 0
                    [payment] => 0
                    [start_date] => 2015-12-08
                    [end_date] => 2016-02-25
                    [closed_date] => 0000-00-00
                    [published] => 1
                    [close_offer] => 0
                    [close_by_admin] => 0
                    [hits] => 0
                    [modified] => 0000-00-00 00:00:00
                    [extended_counter] => 0
                    [winner_id] => 0
                    [cat] => 7
                    [has_file] => 0
                    [file_name] => 
                    [job_deadline] => 79
                    [show_bidder_nr] => 1
                    [show_best_bid] => 1
                    [NDA_file] => NDA file comes here
                    [NDA] => 0
                    [featured] => none
                    [auction_nr] => 
                    [cancel_reason] => 
                    [googlex] => 
                    [googley] => 
                    [approved] => 0
                )

        )

)
Array
(
)
Errors
Array
(
)
Debug Info
Array
(
    [12] => Array
        (
            [DB Read] => Array
                (
                    [Queries] => Array
                        (
                            [0] => SELECT `lesson_data`.`id` AS `lesson_data.id`, `lesson_data`.`userid` AS `lesson_data.userid`, `lesson_data`.`title` AS `lesson_data.title`, `lesson_data`.`shortdescription` AS `lesson_data.shortdescription`, `lesson_data`.`description` AS `lesson_data.description`, `lesson_data`.`picture` AS `lesson_data.picture`, `lesson_data`.`link_extern` AS `lesson_data.link_extern`, `lesson_data`.`max_price` AS `lesson_data.max_price`, `lesson_data`.`currency` AS `lesson_data.currency`, `lesson_data`.`max_price_default_currency` AS `lesson_data.max_price_default_currency`, `lesson_data`.`auction_type` AS `lesson_data.auction_type`, `lesson_data`.`automatic` AS `lesson_data.automatic`, `lesson_data`.`payment` AS `lesson_data.payment`, `lesson_data`.`start_date` AS `lesson_data.start_date`, `lesson_data`.`end_date` AS `lesson_data.end_date`, `lesson_data`.`closed_date` AS `lesson_data.closed_date`, `lesson_data`.`published` AS `lesson_data.published`, `lesson_data`.`close_offer` AS `lesson_data.close_offer`, `lesson_data`.`close_by_admin` AS `lesson_data.close_by_admin`, `lesson_data`.`hits` AS `lesson_data.hits`, `lesson_data`.`modified` AS `lesson_data.modified`, `lesson_data`.`extended_counter` AS `lesson_data.extended_counter`, `lesson_data`.`winner_id` AS `lesson_data.winner_id`, `lesson_data`.`cat` AS `lesson_data.cat`, `lesson_data`.`has_file` AS `lesson_data.has_file`, `lesson_data`.`file_name` AS `lesson_data.file_name`, `lesson_data`.`job_deadline` AS `lesson_data.job_deadline`, `lesson_data`.`show_bidder_nr` AS `lesson_data.show_bidder_nr`, `lesson_data`.`show_best_bid` AS `lesson_data.show_best_bid`, `lesson_data`.`NDA_file` AS `lesson_data.NDA_file`, `lesson_data`.`NDA` AS `lesson_data.NDA`, `lesson_data`.`featured` AS `lesson_data.featured`, `lesson_data`.`auction_nr` AS `lesson_data.auction_nr`, `lesson_data`.`cancel_reason` AS `lesson_data.cancel_reason`, `lesson_data`.`googlex` AS `lesson_data.googlex`, `lesson_data`.`googley` AS `lesson_data.googley`, `lesson_data`.`approved` AS `lesson_data.approved` FROM `pkzaq_rbid_auctions` AS `lesson_data` WHERE `lesson_data`.`userid` = '513'
                        )

                )

        )

)
GreyHead 08 Dec, 2015
Hi dtws2008,

I'm sorry, I don't understand what you are trying to do here. If you want a list of titles with 'edit' links then you might be better using ChronoConnectivity which is designed to handle lists like that.

In ChronoForms you could create a list with links that go to a form and identify the title e.g. . . . &chronoform=some_form&title=999 The the form can load the data for title 999.

Bob
dtws2008 08 Dec, 2015
Thank you, I will use chronoconnectivity.
This topic is locked and no more replies can be posted.