Forums

Get the created cf_id after DB Save

weissmag 21 Jun, 2011
Hi,

I have a form which saves to database using the DB Save event and works fine.

I have multi-select list box which i want to save into an association table.

I want to write a custom code event after the DB Save that will insert the multiple rows into the association table. but i fail to find the just created cf_id.

How do i do that ?
Thanks !
weissmag 21 Jun, 2011
Hi,

Ok, i figured this out, i found the cf_id inside the $form->data['mymodelid']['df_id']

now i wonder what is the correct way to load the values using the DB record loader on success event
i added some custom code that needs the model id, and have set one in the db loader but now the rest of the form is not loaded nor the multi-select.

what is the correct way to do so ?

Thanks again !
GreyHead 26 Jun, 2011
Hi weissmag ,

Have you solved this? My suggestion is not to use the OnSuccess event but to add the succeeding actions after the DB Load action.

Bob
weissmag 26 Jun, 2011
Hi,

Yes I have solved this.

In the OnSuccess event I added a code that loads from the categories association table and add the data into the model_id, than it is displayed in the multi-select box as multiple selected.

Of course I needed to changethe fields in the html of the form to the format name="MODEL_ID[my_multi_select_field][]" and to name="MODEL_ID[my_regular_field]"
like I asked here : http://www.chronoengine.com/forums.html?cont=posts&f=3&t=22310

May I suggest to add a better documentation to each field implication (like in the case of "Load Under Model ID").
In my opinion very good forums (like you have) even with very good search (like you have) and even with highly professional answers(like you definitely have), does not cover the lack of elaborated wiki/documentation.

In any case, is there any reason not to do it in the on success ?

Thanks again
GreyHead 26 Jun, 2011
Hi weissmag,

A agree with you about the documentation - unfortuately it takes time that I don't have right now :-( Hopefully we’ll catch up before too long - there are already a few tutorials appearing.

If the OnSuccess event is working that's fine. It's not always correclty implemented (by me I confess) and it seems easier to continue the main workflow in the OnSubmit event rather than creating new branches for the main flow when they are not strictly needed.

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