Forums

I cant save fields into two differents databases

ideagrup 27 Feb, 2015
I have ONE form
Fields:

Name
Direction
Email
Product

I need save fields in two databases

DataBase 1
Name
Direction
Email

Database 2
Name
Product

In SETUP i have this
[handle arrays]
[db save]
[db save]

I tried all options save under model id, differents model id, etc
I cant save in two databases.
Only i save 1 the first

Can u help me??
GreyHead 27 Feb, 2015
Hi ideagrup,

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

Is the Handle Arrays action breaking the Model ID sub-arrays?

Bob
ideagrup 27 Feb, 2015
Is running, 😀 😀

Only a problem

LIst fields on hadle array i put (Name, direction, Presup[Product]
the second db save save correctly Product field

BUT How can i put the field NAME in the second database??? because is the same field for two databases.

THOMAS
GreyHead 27 Feb, 2015
Hi ideagrup,

Add Custom Code action and duplicate the value, something like this:
<?php
$form->data['Presup']['Name'] = $form->data['Name'];
?>

Bob
ideagrup 27 Feb, 2015
Perfect.😀

Thanks GreyHead

THOMAS
ideagrup 27 Feb, 2015
Ahhh problem

A dont see that my form make two records in each database.

the fisrt ok and second empty

This is the debug.

Array
(
    [option] => com_chronoforms5
    [chronoform] => th_Potenciales
    [event] => submit
    [Nombre] => sdfdsafs
    [Correo] => ideagrup.tomas@gmail.com
    [Empresa] => dfg
    [Direccion] => gfh
    [Poblacion] => dfgaafdsa
    [Cpostal] => 234
    [Provincia] => dfs
    [Presup] => Array
        (
            [Producto] => yyyyyyy
            [Empresa] => sdfdsafs
            [id] => 17
        )

    [Enviar] => Enviar
    [id] => 38
    [ip_address] => 81.43.178.221
)
Array
(
)
Errors
Array
(
)
Debug Info
Array
(
    [2] => Array
        (
            [DB Save] => Array
                (
                    [Queries] => Array
                        (
                            [0] => INSERT INTO `#_th_Potenciales` (`Nombre`, `Correo`, `Empresa`, `Direccion`, `Poblacion`, `Cpostal`, `Provincia`, `Enviar`, `user_id`, `created`) values ('sdfdsafs', 'ideagrup.tomas@gmail.com', 'dfg', 'gfh', 'dfgaafdsa', '234', 'dfs', 'Enviar', '0', '2015-02-27 16:21:11');
                        )

                )

        )

    [5] => Array
        (
            [DB Save] => Array
                (
                    [Queries] => Array
                        (
                            [0] => INSERT INTO `#_th_Presupuestos` (`Producto`, `Empresa`, `user_id`, `created`) values ('yyyyyyy', 'sdfdsafs', '0', '2015-02-27 16:21:11');
                        )

                )

        )

    [3] => Array
        (
            [Email] => Array
                (
                    [0] => An email with the details below was sent successfully:
                    [1] => To:ideagrup.tomas@gmail.com, ideagrup@yahoo.es
                    [2] => Subject:Solicitud de presupuesto web
                    [3] => From name:Presupuestos ThomasWebb
                    [4] => From email:presupuestos@thomaswebb.es
                    [5] => CC:
                    [6] => BCC:
                    [7] => Reply name:Nombre
                    [8] => Reply email:
                    [9] => Attachments:
                    [10] => Body:
<table>
<tr><td>Nombre</td><td>sdfdsafs</td></tr>
<tr><td>Correo</td><td>ideagrup.tomas@gmail.com</td></tr>
<tr><td>Empresa</td><td>dfg</td></tr>
<tr><td>Dirección</td><td>gfh</td></tr>
<tr><td>Población</td><td>dfgaafdsa</td></tr>
<tr><td>Código Postal</td><td>234</td></tr>
<tr><td>Provincia</td><td>dfs</td></tr>
<tr><td>Producto</td><td></td></tr>
</table>
                )

        )

)
GreyHead 27 Feb, 2015
Hi Thomas,

The Debugger only shows one INSERT into each table.

Is it possible that the form is looping and re-loading the On Submit event with no data?

Bob
ideagrup 27 Feb, 2015
Ok i think the same

But what do you think about the
Solution?

Is posible that the problem is the events order?
GreyHead 28 Feb, 2015
Hi ideagrup,

No the events order looks OK. I think that the form maybe submitting twice. Try adding some very basic serverside validation and see if that stops the problem - just check for one required field.

Bob
ideagrup 02 Mar, 2015
Curious situation

In different computers is running ok or not running ok

Using chrome navigation.

is the first time i see this problem.

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