Forums

comprehension Questions (DB-Save and multiple autocomplete)

grafik 04 Mar, 2013
Hi
i had a few more or less complicated Questions:

Autocomplete
did i need for every Autocomplete Processor an own Event or can i use the same Event for all Autocomplete Processor?
Why both (Processor and Loader) had Field Name, Min-length and max-choice inside and not only one of this?
i had several Input-Fields at the same page, 3 of it should use a Autocomplete Loader.
they load 3 different columns of the same db-table.

Generally to do that i need :
3 Autocomplete Loader before the show html Action. 3 different Events, each with a single Autocomplete Processor in it?
is that Correct? or is there a more simple way to do that?

DB-Save
I had a form with 2 DB-Save actions, one save to a table created by chronoforms, one should save to a separate table of the same DB.
somehow the save-action for the separate table only works when a record exist that had the same primary-key like the one that i would save. the primary-key of the separate table is a int(11), and the value came from a hidden field inside the form.
of course the record for the chronoforms table are always created, no matter if the other db-save work or not. save order doesnt matter.
the debugger shows no error.

that means i could update existing records at the second table, but i cant create new records.
Someone had a clue what i did wrong? or why the second table is able to update existing records, but cant create new record in it.


Best Regards and thanks for every help
grafik
GreyHead 05 Mar, 2013
Hi grafik,

did i need for every Autocomplete Processor an own Event or can i use the same Event for all Autocomplete Processor?

You could possibly use one but the coding gets more complex, it's probably easier to use three. To use one you'd need to identify which element was making the request and return the appropriate results set.

Why both (Processor and Loader) had Field Name, Min-length and max-choice inside and not only one of this?

I don't know :-(

The DB Save should work perfectly well with your table. The table must have a numeric primary key, I don't think that it needs to auto-increment, though usually they do. Your form data should have either an empty value for the primary key column, or an empty one.

What value does the hidden input have for a new record?

Bob
grafik 06 Mar, 2013

What value does the hidden input have for a new record?


why? it is always an integer for now. had it to be emty?
then more i test i belive it had to be emty, when it is a new record.

for now it is a pre-defined number, that is saved well to the DB that is created by chronoforms.
my primary-key is not an auto-increment integer, because i have for example:
100 Unique Numbers, one for each customer, and everyone should get a record after first save.
one DB save the newest value, and one DB track every save. but customer do this not in order of the numbers. and the are for example unique 6-digit long numbers.

i wish to be able to add this unique number (that is also the primary-key) as a parameter to the url. with that i can easy load and save existing records from/to DB just use the primary-key value, that was the reason to do it like that.

Debug

Data Array:

Array
(
    [option] => com_chronoforms
    [user_id] => 1
    [chronoform] => my_event
    [event] => editdatasave
    [cf_sid] => bccc61ad0ce0a8537ae3278c3630c6f9
    [Itemid] => 
    [prename] => prename
    [name] => name
    [firm] => firm
    [adress] => adress
    [phone] => phone
    [mobile] => mobile
    [email] => email
    [save] => save
    [prim] => 1
    [chronoform_data] => Array
        (
            [cf_modified] => 2013-03-06 09:39:22
            [cf_uid] => 45481438d12e6c61dd11840311aa351b
            [cf_created] => 2013-03-06 09:39:22
            [cf_ipaddress] => 000.000.000.000
            [cf_user_id] => 0
            [option] => com_chronoforms
            [user_id] => 1
            [chronoform] => my_event
            [event] => editdatasave
            [cf_sid] => bccc61ad0ce0a8537ae3278c3630c6f9
            [Itemid] => 
            [prename] => prename
            [name] => name
            [firm] => firm
            [adress] => adress
            [phone] => phone
            [mobile] => mobile
            [email] => email
            [save] => save
            [c37eca7174b1855ff2bfd421d8d80102] => 1
            [scrnid] => scrn001
            [prim] => 1
            [cf_id] => 48
        )

    [chronoform_data_cf_id] => 48
    [chronoform_data_prim] => 1
)

Validation Errors:

Array
(
)


Primary-Key is cf_id (for standard table) and prim (for additional table)
For this debug : When a record with prim=1 exist it will be updated, else it will not be saved.
Even when same values are used.
Debug-Message didnt change, when a record exist or not. (only the primarykey of cf_id raise up because it is an auto-increment value)
GreyHead 06 Mar, 2013
HI grafik,

ChronoForms uses the Joomla! bind() and store() methods in the DB Save action and my understanding was that a new record would be created if the primary key value was either (a) empty or (b) did not exist in the table. Your post is suggesting that only (a) is true. That could be correct, I'd need to check the Joomla! code to be sure.

I took a look and the store method says:

// If a primary key exists update the object, otherwise insert it.



I'm not clear what is happening in your case :-(

Bob
grafik 06 Mar, 2013
Hi Bob, thanks for looking at it.🤔

I'm not clear what is happening in your case :-(


Please can you create a little form with a few, fields and an event after submit that have 2 DB-Saves. one to a table that is created with chronoforms, and one that only include the values.
set the primary-key of the second DB as integer.
and insert 2+ rows with datas into that table with different primary-key.

after that try to add a new row of data, and try to update data with the Form.
if same happens like here, update works, add new did not work when value for primary-key is filled out, when it is blank, a new record is created with the value of 0 for the primary-key.

instead of create a new you can use the attached backup of my test-form, and create only te DB-tables.
inside this form: the value for the Primary-key is set by the 3 field. and i can load data into from the db with adding &prim=INTEGERVALUE from the url.

just to get sure that it is not only a problem with my server. 😑

thank you very much.
grafik
GreyHead 06 Mar, 2013
Hi grafik,

To save some time please send me a Create Table statement for the second table.

Bob
grafik 08 Mar, 2013
hi Bob
have you become the PM that i send to you?
any news about "the fact": save to a second DB-Table with a primary-key that is set, but not exist yet didnt work.

Or did it work at your server?

I dont need a reply before monday, because i will see it not before monday anyway.

Kind Regards
grafik
GreyHead 08 Mar, 2013
Hi grafik,

I have it thank you, just haven't found time to look yet :-( Will try to get it cleared over the weekend, there's a little backlog of queries that need some research to check them out . . .

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