Forums

Save multiple data in two different tables --> fatal error

seagul 20 Oct, 2015
Hello,

what I need to do:
1. Manager fills in form with multiple employee email-addresses
2. Save manager contact data to #__cf_company
3. Save multiple employee to #__cf_company_employees

Do I need the DBSave to get the cf_id for the manager? So I can do the second DBSave for employees after the first?

#__cf_company
Data
  cf_id = 54     (--> un_id for employee)
  email_mang = xxx@yyy.net

#__cf_company_employees
Data 1:
  cf_id = 1
  un_id = 54
  ma_email = xxx@yyy.net
Data 2:
  cf_id = 2
  un_id = 54
  ma_email = zzz@aaa.net


Debug info before save an adaption of data:
Array
(
    [option] => com_content
    [view] => article
    [id] => 16
    [Itemid] => 136
    [chronoform] => unternehmen_adv
    [event] => submit
    [quickcheck] => exit
    [anrede] => Frau
    [name] => test
    [email_mang] => xxx@yyy.net
    [telefon] => 2adf
    [unternehmen] => 34asdf
    [emailMA] => Array
        (
            [1] => Array
                (
                    [ma_email] => xxx@yyy.net
                    [cf_id] => 
                    [un_id] => 
                    [quickcheck] => 
                )

            [2] => Array
                (
                    [ma_email] => zzz@aaa.net
                    [cf_id] => 
                    [un_id] => 
                    [quickcheck] => 
                )

        )

    [start_check] => Quick-Check Einladung versenden
    [qc_name] => Exit Interview
    [enddatum] => JDate Object
        (
            [tz:protected] => DateTimeZone Object
                (
                )

            [date] => 2015-11-03 07:16:17.000000
            [timezone_type] => 3
            [timezone] => UTC
        )

    [enddatum_format] => 03.11.2015
    [cf_id] => 54
    [ip_address] => xxxxx
)


I know how to do the coding. But when I submit my form I get the error:
Fatal error: Cannot redeclare class GCore\Models\emailMA in /www/htdocs/administrator/components/com_chronoforms5/chronoforms/actions/db_save/db_save.php(73) : eval()'d code on line 4
GreyHead 20 Oct, 2015
Hi seagul,

Hmmm . . . bit odd,, All your settings look correct yet when I check the code there is a check to see if the class is already declared so the error shouldn't occur. There may be a bug there, but I haven't seen it before.

Do you have the most recent version of CFv5 installed? If not please upgrade and see if that fixes it. If it doesn't please ask Max to take a look using the Contact Us menu above and linking to this thread.

Bob
seagul 20 Oct, 2015
I contacted Max because I have CF5.0.10
Or is there a github version or so?
GreyHead 20 Oct, 2015
Hi seagul,

No, sorry, there's no GitHub version.

Bob
Max_admin 24 Oct, 2015
Hi,

Do you have the debug data available after the first save ? does the first save actually work ?

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
seagul 26 Oct, 2015
Hi,

yes, the first save does work.
Array
(
    [11] => Array
        (
            [DB Save] => Array
                (
                    [Queries] => Array
                        (
                            [0] => INSERT INTO `#_cf_unternehmen` (`quickcheck`, `anrede`, `name`, `email_mang`, `telefon`, `unternehmen`, `enddatum`, `user_id`, `uniq_id`, `created`) values ('mzu', 'Frau', 'Test', 'test@test.net', '013154132133', 'test', '2015-11-09 23:12:18', '0', '76117c1019cc6af6e741b9dde37505d4ae41cae2', '2015-10-27 00:12:18');
                        )

                )

        )

)


And actually the second DB Save does work too, but I cannot show the debug data, because I get the error message. But there are two new lines in the database, if I add two multiple entries.
And I get a cf_id for the new entry in my $form->data

Best regards,
Sigrid
Max_admin 28 Oct, 2015
I'm not sure why the error occurs, please try to switch the places of the db save actions ? do you get the same error ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
seagul 04 Nov, 2015
I changed the order and there is still the same error message...
seagul 05 Nov, 2015
I recreated the whole form with exactly the same fields and code.
Now it works...
Hm, strange...
seagul 05 Nov, 2015
Ah, now I know the problem.

The error occurs, if I add the form as module!!! If I use it as a normal menu item then it works perfectly well without error. As soon as I display the form in a module I get the fatal error.
This topic is locked and no more replies can be posted.