November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
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.
Ah thanks, I was hoping I didn't have to rewrite all the form logic... I have the CreatingContent event working.
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.
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
If you create your own formcontainerblock, inherit the original one and the controller will handle your new block as well
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.
I did not consider create new block from content area, it did work for me using both "Blocks" and "forms" in the asset panel.
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?
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!
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?
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.