Forums

CF5 module DB not working while component works

seppo 13 Sep, 2016
My system:
Joomla 3.6.0
Chronoforms 5.0.12
ChronoForms Module 5 RC1.2

I made a form which saves info from textbox to database, identified by userid. After initial saving, user can go again to same form, and edit the saved info.
This works fine when I run it from page, that is accessed with menuitem set as chronoform5, thus it works when run straight from component.

However, if I use CF5 module, it does not save the original data. If I first save the first info at the component page described above, I can modify it at the CF5 module, and it saves the information just as it should - all working fine. Thus the UPDATE of database works in both cases. But INSERT does not. If there is no previous record for same user, the new data won't be saved, if I use the module. I do not get any error message, and the message written to "display message"-event will show fine. It just does not INSERT it to database.

Since all is working correctly when reaching the form from component-page, I suppose the form itself is built correctly. But since the same form does not work correctly if accessed through CF5 module, I suppose the module has a bug of some sort.
GreyHead 14 Sep, 2016
Answer
1 Likes
Hi seppo,

Please add a Debugger and check exactly what is happening. If the Primary Key in your table is called ID and the form module is in an article page then the article ID from the page URL may be being used as a record identifier - so that insert isn't happening because another record is being wrongly updated.

If this is the problem then the simplest fix is to change the name of your primary key column to say cf_id instead of id.

Bob
seppo 14 Sep, 2016
Thanks Bob,

that fixed the problem. When adding the table through CF, it suggested to use id as primary key (not such in form), and so it was there. So this was not a bug, but as a suggestion to future versions: when adding a table to form with CF, it could by default suggest something else than id, i.e. cf_id as you suggested here.

For others with similar problem, after changing name of id-field through phpMyAdmin, I had to Delete Cache from CF, for it to update new structure for that table.
GreyHead 15 Sep, 2016
Hi seppo,

It used to be 'cf_id' by default in CFv4 - I don't know why Max changed that to 'id' in CFv5 as it causes more problems than necessary :-(

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