How to set allow anonymous by default

Vote:
 

Is there an easy way to override the default settings for FormContainerBlock so that AllowAnonymousSubmission is equal to true by default? There are a few settings we wish to customize in this block and the allow anonymous is one of the most important ones because we MUST allow anonymous on all forms or they will not work. Setting this to true by default will prevent users from accidently creating forms that users cannot submit. 

#149430
May 31, 2016 21:19
Vote:
 

Either create your own Form block and that inherits from FormContainerBlock override SetDefaultValues, or you can hook up to the CreatingContent event

http://world.episerver.com/documentation/class-library/?documentId=cms/7/d9d430f7-90df-92cc-5a44-e1d127adb30c

Cast eventArgs.Content to FormContainerBlock and set the value.

#149439
Edited, Jun 01, 2016 7:57
Vote:
 

Ah thanks, I was hoping I didn't have to rewrite all the form logic... I have the CreatingContent event working. 

#149492
Jun 01, 2016 18:27
Vote:
 

Alf,

Just realized while the event handling does work for creating a new form under the 'Form' assets tab, while creating a form as a block does not trigger this event until after the form is saved. This means that the values do not get set until the form has been created and saved, thus users don't know that it is going to overwrite their values if they decide to leave it unchecked on purpose for some reason. 

What all is required to create my own form block that inherrits from FormContainerBlock? Looking at the FormContainerBlockController if I wanted to make a custom FormContainerBlock I would have to redo almost all of the form controller logic. I'm guessing this is the only way to accomplish this. Scares me overwriting the logic since any form updates and my code is now out of sync. 

#149573
Jun 03, 2016 16:55
Vote:
 

Did you use creating or created content? This works for me

https://github.com/alfnilsson/EpiserverForms/blob/master/Toders.Forms.Web/Business/Forms/AllowAnonymousSubmissionDefault.cs

  • Create new Form (or create new block and select the Form container)
  • Give it a name if you didn't in the first step
  • Go to All Properties mode and verify that the property "Allow anonymous submissions" is checked.

If you create your own formcontainerblock, inherit the original one and the controller will handle your new block as well 

#149576
Edited, Jun 03, 2016 17:07
Vote:
 

I put a breakpoint on Creating and Created. I did the logic in Creating like you did. If you create a new form by clicking in a content area this does not work (Click "Create new block" in content area. Choose form type). Creating does not get triggered until after the form has been saved. YOu will notice it will not prompt you to change the name of the form until you save it and which point the "creating" event is then triggered. 

#149579
Jun 03, 2016 17:56
Vote:
 

I did not consider create new block from content area, it did work for me using both "Blocks" and "forms" in the asset panel.

#149580
Jun 03, 2016 18:00
Vote:
 

Just  checked and noticed that the create block from ContentArea does things in a reversed order basically. Also noticed that the FormContainerBlock didn't hook up to inherited Block Types either :\

How common is it that your editors use that function compared to the Forms tab in the Asset Panel?

#149582
Jun 03, 2016 18:57
Vote:
 

I ended up figuring out a solution for this. I inherited from FormContainerBlock and gave it a new GUID and Display name. This created two form blocks. I went into admin -> Content Types and disabled the ability for anyone to create a new Form Container Block type thus forcing users to use my custom block. Creating a new form automatically handles this and chooses the custom form by default. Thanks for your suggestions and help!

#149583
Jun 03, 2016 19:12
Vote:
 

I believe inherit from FormContainerBlock and override SetDefaultValues() is the good solution.

I also think, by default, AllowAnonymousSubmission should be true. We might change this in Forms 3.0

@Alf Nilsson noticed that the FormContainerBlock didn't hook up to inherited Block Types either :\

Could you please, elaborate this?

#150154
Jun 13, 2016 9:12
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.