Forums

Form creates new record instead of updating existing one dis

peterswa62 01 Oct, 2012
I am using version 4 of Chronoforms. I have a form which loads a record for editing using DB Load Recorder and various fields. I have draggged on the On Submit event the DB Save function and set it to the right table and Model ID, but instead of updating the existing record it creates a new one.What am I missing out?
GreyHead 01 Oct, 2012
Hi peterswa62 ,

You need to make sure that the primary key of the record you are editing is included in the form data. Usually you do this by adding it in a hidden input.

Bob
peterswa62 02 Oct, 2012
It still doesn't work! I've set the DB Field of the DB Record Loader to id:- the primary key of my table. Set the name of a hidden field to id on the form. Is there another way of doing this?
GreyHead 02 Oct, 2012
Hi peterswa62 ,

Is the value of the hidden input set correctly? i.e. does it pick up the primary key value?

Bob
peterswa62 02 Oct, 2012
The Field Name and Field Id are set to "id" the name of my primary key in the table. The Field Value is set to "2" to test it on updating this record with this primary key. Is this right?
peterswa62 03 Oct, 2012
How do you set the Hidden Field exactly?
GreyHead 03 Oct, 2012
Hi peterswa62,

Drag a Hidden element into the Form Preview box.

Set the name to id

For testing you can hard code a value in the Value option box.

For production leave the Value box empty and maker sure that there is a value of id set in the $from->data array - loaded from a DB Record Loader, added to the URL, passed from a previous form page, set up in a Custom Code action, any of these will work.

Bob
peterswa62 03 Oct, 2012
Sorry to be a nuisance but it still doesn't work all I get is a blank form when I do what you say.

However when I put id = 2 in the WHERE clause on DB Record Loader it correctly loads the record with this primary key, but when you save it creates a new record. When I set the hidden field value to 2 and the WHERE clause to blank:- nothing.

For some reason it cannot see the hidden field which I have put on the form. Is it to do with the version:- I am using the latest version of Chronoforms v4. Is it to do with the hidden elememt? I am using something called Hidden Box which I dragged from advanced elements tab. Is it a wrong setting with DB Record Loader? Is it a wrong setting with with DB Save? Is it a bug? I cannot figure it out.
GreyHead 03 Oct, 2012
Hi peterswa62,

Please do View Source on the form and see if the hidden input is correct and is inside the <form> tags - it should be.

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

Note: if you are using the Easy Wizard you can turn on Debug on the Others tab.

Bob
peterswa62 05 Oct, 2012
Hi I checked the source code like you said and the hidden field is there before the form tag alongside another hidden field presumably created by ChronoForms :-
<input type="hidden" value="2" name="id" />
<input type="hidden" name="975c2f6bdd5fce206b794404ba5e8f20" value="1" />
</form>


I put A Debugger on the submit action with the hidden field setting id to 2 to load this record and I have Model Id called client in DB Record Loader. When I press submit form and this is what I got:-

Array
(
    [option] => com_chronoforms
    [chronoform] => ViewClient
    [event] => submit
    [Itemid] => 
    [client] => Array
        (
            [cf_uid] => ff87f0b004f09c2dd337e80b948ff0f7
            [cf_created] => 2012-10-05 06:53:29
            [cf_created_by] => 0
            [cf_ipaddress] => 109.153.116.68
            [cf_user_id] => 0
            [title] => 
            [firstname] => 
            [middlename] => 
            [lastname] => 
            [address1] => 
            [town] => 
            [county] => 
            [postcode] => 
            [NI_No] => 
            [datestarted] => 
            [telephone] => 
            [telephone2] => 
            [email] => 
            [ref] => 
            [company] => 
            [authentication_code] => 
            [status] => 
            [status2] => 
            [Reg_No] => 
            [PAYE_Ref] => 
            [VAT_No] => 
            [year_end] => 
            [account_due] => 
            [next_annual_return] => 
            [price_for_year] => 
            [account] => 
            [account_return] => 
            [notes] => 
            [id] => 125
        )

    [address2] => 
    [update_client] => Submit
    [id] => 2
    [975c2f6bdd5fce206b794404ba5e8f20] => 1
    [client_id] => 125
)
Validation Errors: 
Array
(
)
GreyHead 06 Oct, 2012
Hi peterswa62,

It looks form this as though the id of the record being edited is 125 so You'd need to have that in the hidden input to save to the same record???

Bob
peterswa62 08 Oct, 2012
I put id = 2 in the hidden field and it set the id to 125. There are 123 records in the database so its just creating a new record in the database.
GreyHead 08 Oct, 2012
Hi peterswa62 ,

I'm sorry but none of this makes any sense to me :-(

Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.

Bob
GreyHead 08 Oct, 2012
Hi peterswa62,

Thanks for the form backup. I seem to have landlord666 restored OK - but the form has no DB Record Loader or DB Save actions as far as I can see.

Bob
peterswa62 08 Oct, 2012
The DB Save and DB Record Loader were definitely in the form before back up.
GreyHead 08 Oct, 2012
Hi peterswa62,

And no sign of a hidden input either :-(

I'm afraid that it doesn't tell me much.

Bob
GreyHead 08 Oct, 2012
Hi peterswa62,

I'm sorry that was my mistake - I was looking at the wrong form :-(

I think that a part of the problem is that you are using a ModelID. The name of the hidden input probably needs to take account of this and be client[id] - or something similar. See the notes under 'Load under Model ID' in the DB Record Loader.

Bob
peterswa62 08 Oct, 2012
The way you showed me does not work with me at all:- updating a record with a hidden field. Rather than waste any more time I have reported this as a bug. The only other way of doing it as far as I can see is to put a custom code section on the on submit event and use PHP. Is that correct?
GreyHead 08 Oct, 2012
Hi peterswa62,

As I noted on your other post there is no bug here. The method I have shown you will work - provided that you adapt it to work with the other settings you have chosen.

Bob
bijilal 27 Mar, 2013
Same problem here.
Created a form with three fields and save it as frm1.
1. When I go the front end I don't see any of the three fields
2. When I open the same form to edit and save, it is asking to enter a new form name.

I am struggling with this for the last few days and decided to post on the forum. Once I see the basics working I will see if I can buy a subscription.

Thanks
Bijilal
GreyHead 28 Mar, 2013
Hi Bijilal,

I'm not sure that is the same problem at all.

Please see this FAQ which may help you get started.

Bob
bijilal 28 Mar, 2013
Hi Bob,

I followed the ttp://www.chronoengine.com/faqs/view/2599/how-do-i-build-a-first-form.html and created a brand new form with a one text field and a submit button. For the event "On Load", I added show html and a thank you message for "On Submit". After saving the form I am go to preview the form, but I cannot see the test field and submit button. So I went back to the form and looked at the events tab, and I noticed that "show html" and "Thank you message" both are gone. Wondering where is it getting lost after saving the form initially.

If I drag another show html into the events area, it displayed as "Show html(2)", which means that the form knows there is already one there before. But I am not able to see the previous one and it is not getting called when I preview the forms.

I am running Chronoforms version - 4.0 RC3.5.2 on Joomla! 2.5.9 Stable.

Thanks
Bijilal
GreyHead 28 Mar, 2013
Hi Bijilal,

This sounds like some kind of conflict. Are you sure that you have the 1.6-2.5 version of ChronoForms installed?

By all means email or PM me the site URL and a SuperAdmin login and I'll take a quick look.

Bob
bijilal 29 Mar, 2013
Hi Bob,

I removed the choronoforms completely and reinstalled it. The file I used is - Chronoforms_V4_RC3.5.2_J1.6. and I am on version 2.5.9 of Joomla.

Created the form called frm1 (it has a text box called name and the submit button)
On the action/events
for Onload - I added "show html"
For On Submit - I added "show thanks message"

Saved it did a preview. That time I can see the form.

You say save and close, then go back an open the form and say preview, the "Show HTML" and the "show thank you message" from the site is completely gone though it was applied/saved before.

Something is not right, and not sure why the previous save disappeared. I think this looks to be the basic problem, once I get pass that, I can explore how to use this for saving data into the database and also retrieve the same and show it on the form. Once I get a hang of the basic functionality I will probably buy a validate copy for my use.

If you can provide me an e-mail, I can send you the site information for you to login and check on it. It did not look right for me to post that type of information on the forum.

thanks
Biji
GreyHead 29 Mar, 2013
Hi bijilal,

You can email or PM me using the icons under my picture on the right of my posts.

Bob
GreyHead 29 Mar, 2013
Hi bibilal,

I found your PM, thank you, and took a look. I can't explain the problem and haven't seen it quite like that before. I can confirm that the data for the actions is being posted when you click save but doesn't reappear again. It's very odd. The next step in debugging would be to check and see if the form info is being saved in the database as that would tell if the problem was on the save or the re-load.

The only odd thing I spotted was that the Wizard Save gives a HTTP 303 'See other' response instead of an HTTP 200 'OK' message. I wonder if this has something to do with the errors.

Sorry not to be more help :-(

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