Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ash 18 posts 88 karma points
    Mar 05, 2020 @ 10:42
    Ash
    0

    Umbraco Forms Partial submission on v8 constructor

    Hi

    v8 for forms doesn't allow parameterless constructor when inheritting from

    UmbracoFormsController

    class. So for instance if I want to override OnFormHandled method like I do in v7, I'll now need to provide Instances for several classes. Question here is where do I get these instances without newing up on each request?

    Here is v8 constructor parameters:

     public UmbracoFormsController(DistributedCache distributedCache, IFormStorage formStorage, IRecordStorage recordStorage, IRecordService recordService, FieldCollection fieldCollection, IFieldTypeStorage fieldTypeStorage, IFieldPreValueSourceService fieldPreValueSourceService, IFieldPreValueSourceTypeService fieldPreValueSourceTypeService, IUmbracoContextAccessor umbracoContextAccessor)
            {
    
            }
    

    Does anyone know how to provide instances to these parameters. Are we using DI in umbraco v8 which does that for us?

    I really like Umbraco forms and we are running umbraco cloud but this is becoming an issue as there are several custom umbracoformcontrollers we use for v7, we need to build for providing partial form submission. If you know other ways to partially submit forms using Umbraco forms in v8 please let me know. This is our major hold back on v8

    By partial submission i mean, on each next button press data is saved to DB before Resuming to next page of the form.

  • Matthew Wise 271 posts 1373 karma points MVP 5x c-trib
    Mar 05, 2020 @ 18:25
    Matthew Wise
    0

    Hi Ash,

    Yes Umbraco has DI that should handle all those.

    Matt

  • Ash 18 posts 88 karma points
    Mar 05, 2020 @ 18:34
    Ash
    0

    Thanks Matt, could u please share a snippet on how can I grab the instance from Umbraco DI many thanks

  • Matthew Wise 271 posts 1373 karma points MVP 5x c-trib
    Mar 05, 2020 @ 18:37
    Matthew Wise
    1

    You shouldn't need to do any DI the composer's should all be wired up so you can do

    public MyUmbracoFormsController(DistributedCache distributedCache, IFormStorage formStorage, IRecordStorage recordStorage, IRecordService recordService, FieldCollection fieldCollection, IFieldTypeStorage fieldTypeStorage, IFieldPreValueSourceService fieldPreValueSourceService, IFieldPreValueSourceTypeService fieldPreValueSourceTypeService, IUmbracoContextAccessor umbracoContextAccessor) :base(params) {

        }
    

    Sorry about formatting am on my phone

  • Ash 18 posts 88 karma points
    Mar 05, 2020 @ 18:47
    Ash
    0

    Thanks Matt for pointing in right direction.. I will run through DI route

  • Stefan Orr 6 posts 76 karma points
    Aug 03, 2020 @ 04:20
    Stefan Orr
    0

    Hey did you ever get this sorted?

    I'm needing to do the same thing, so if you have any info or snippets that could help me that would be great, Thanks

  • Angel 54 posts 111 karma points
    Dec 05, 2023 @ 18:32
    Angel
    0

    Does anyone have any working code sample for Umbraco 8 and Forms 8 that can do partially saved data in forms?

    Thanks in advance.

Please Sign in or register to post replies

Write your reply to:

Draft