Load data from DBRead into Multiplier

tshirley 29 May, 2016
Hi there,

I have a requirement to present a set of existing records to a user for update. I want the records all presented at the same time, so a Multiplier Container and content seems to be the answer.

I can use DBRead to select the records and place them in an array:



[Tokens] => Array
        (
            [0] => Array
                (
                    [cf_id] => 13233
                    [tokenCustomerID] => 22223333
                    [expirymonth] => 12
                    [expiryyear] => 18
                )

            [1] => Array
                (
                    [cf_id] => 13287
                    [tokenCustomerID] => 111122223333
                    [expirymonth] => 03
                    [expiryyear] => 18
                )

        )


How do I map this array onto my multiplier? The aim is to allow editing and then a DBSave to get the data back into the table.
tshirley 29 May, 2016
Hi,

Problem solved, sorry to trouble you. I had forgotten to set the Data Path in the Multiplier to the array name.

Cheers

Tim
johnoathome 01 Jan, 2017
Hi Tim,

Good tip loading from the db into a multiplier, thanks.

I can handle any updates with dbsave, but just wondering how you managed the case where a user deletes a record? I'm thinking it may be necessary to use js to capture the onclick event then some custom code to delete the record. I'd appreciate any tips on how you have handled this.

Cheers
John
GreyHead 01 Jan, 2017
Hi John,

I'm not sure that I've ever done this with a re-loaded multiplier. I think one way would be to make a list of the multiplier row IDs when the form loads, save that in a hidden input, or in the user session. Then when the form submits you can check if any row IDs are missing and delete, or flag as deleted, any matching records.

Bob.
johnoathome 01 Jan, 2017
Hi Bob,

I actually figured this out myself after trying the onclick approach. I should have been able to get the class of the multiplier contents div with jQuery parent() but the results were unpredictable, I guess because the multiplier inserts the divs into the DOM dynamically.

Anyway I've started working up a PHP script that saves the original array and compares it to $form->data on save, pretty much exactly what you suggested. This will be more reliable in the long run.

Thanks for getting back.

John
Max_admin 23 Jan, 2017
Hi,

Stuff like this is now much easier using ChronoConnectivity v6🙂

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
johnoathome 28 Jan, 2017
Hi Max,

I've been having a bit of a play with Chronoconnectivity. It looks very powerfull but I'm not quite over the learning curve. As for for CC6, I'm still on PHP 5.5.9 so not quite ready for it yet.

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