Umbraco forms 12 - partially submitted form using ?recordId=
j
Hello, Does anyone know how I could repopulate an Umbraco form using ?recordId= for a partially submitted form? I could not see ny partial submissions in the database so was wondering if i needed to do something custom or not πŸ™‚
j
which setting @Jemayn :). Yea i can back back to a submitted form but not one i have not submitted. I.E i have gone to the next page but not completed.
StoreRecordsLocally?
j
Oh sorry I misunderstood your question, not sure how/if you would accomplish it
c
In that scenario, I would have a save button which submits the form but the record has 'complete' field which is set to false. And only set the field to true if the submit button is clicked. That way you can save the data on the server side
j
ah ok, so hve a custom save button that saves the data but sets the 'complete' field to false. Ok i will give that a go πŸ˜„
Hi @CodeSharePaul added a submit button but that does not submit the form unless you are in the last step? Also the work flow does not get fired? Have you done this before? Just trying to make my life simple before doing custom code 😦
c
Have you tried doing it in a single step form first. I would probably create a custom workflow too
j
@CodeSharePaul I have but the custom workflow only gets fired on the last step?, which would make sense. What do you mean by try in a single step form first? I can get that to work becuse the single step form i am on the last step. The problem is on 2+ step form, the submit and workflow only appear to get triggered on that final step. I will try and see if I can hook into the submit event again and try in that way
c
You could create a theme for your form and in that edit the view for the form so that the submit button is on each step.
j
@CodeSharePaul yea that's what I did, but when i submit what should i do then? Should i try and hook into the submit event?
c
Yeah or add a save button to the form instead of the submit one and when it triggers the submit of the form detect if the save or the submit button triggered it. You should be able to see it in the keys of the form
j
Thanks @CodeSharePaul really apricate it. I see what you are saying @CodeSharePaul however, right i think thats what missing i did not mnage to hook into the save event of the form. Has this changed in Umbraco 13? I should just be able to create a controller and inherit (cannot remember the interface)?. Fingers crossed this will make my life ALOT similar, the alternative seems alot of work 😦
@CodeSharePaul so new issue. I can hit the 'save' button and hot protected override void OnFormHandled(Form form, FormViewModel model) However in order to save, i need a record which i dont have here? What do you think, create a new record?
c
Yes the idea is you create a record and have a field with a stage to say if the record is complete or not and you don’t set it to complete until the final submit button is hit.
j
I see, any ideas where I get the fields (string)and other parameters? I assume from the constructor and the model / form? Sorry I have never done this before and just asking as it sounds like you have πŸ˜„
c
I’ll check tomorrow when I’m at my desk
j
Thanks @CodeSharePaul i really do appricate your help ALOT πŸ˜„
c
You can access the fields with this
Copy code
cs
public override WorkflowExecutionStatus Execute(WorkflowExecutionContext context)
{
    var allFields = context.Form.AllFields;
}
j
@CodeSharePaul i cn override this from UmbracoFormsController?
Just to be clear i am going to be in OnFormHandled() when the form gets submitted
c
My example was for a custom workflow. sorry
j
Thats ok, @CodeSharePaul just trying to understand if this is possible thats all πŸ™‚
s
No record is created until the form is fully submitted, so this is not possible out of the box no. Not sure where the partially submitted forms are stored though, not in the database I can see, otherwise you might have been able to hack it. It's a long standing feature request for the team though: https://github.com/umbraco/Umbraco.Forms.Issues/issues/409
j
Thanks @Sebastiaan think its possible to save to the umbraco DB as partically submitted? If not i will save them in a seperate DB with a GUID
s
Probably not a good idea, Forms might get confused and break.. not sure though
j
Thanks @Sebastiaan i have got it to submit the whole form while being only on step 1 / 3 for example. Now just battling with validation (which i may or maynot win)
9 Views