Quantcast
Channel: Optimizely Search & Navigation
Viewing all articles
Browse latest Browse all 6894

How to exclude Form elements from a custom FormContainerBlock and include elements for a custom FormContainerBlock?

$
0
0

Hi!
I have created a new class that inherits from FormContainerBlock (lets call it MyCustomFormContainerBlock).. and so far everything works great, I can use it just fine with EPi Forms.

I also needed to create a few custom ElementBlocks, which I simply did by creating a new class and inherit from whichever current implementation of a default element that fit my needs the best.. for instance:

[ContentType(GUID = "{771addcf-0174-493b-b97c-6002ef88905e}", GroupName = "MyCustomElements", Order = 2000)]
[AvailableValidatorTypes(Include = new Type[] {typeof (RequiredValidator), typeof (RegularExpressionValidator), typeof (EmailValidator), typeof (DateDDMMYYYYValidator), typeof (DateMMDDYYYYValidator), typeof (DateYYYYMMDDValidator)})]
public class MyCustomTextboxElement : TextboxElementBlock
{
[Display(
Name = "Something custom",
Order = 2999)]
 public string SomethingCustom { get; set; }
}

And I also created a controller with an action for the above Element:

public override ActionResult Index(MyCustomTextboxElementBlock currentBlock)
{
    var path = "~/Views/Shared/ElementBlocks/TextboxElementBlock.ascx";
    return PartialView(path, currentBlock);
}


Everything renders just fine, and it all works just fine with forms.. however.. I would like to be able to only show my custom elements for the MyCustomFormContainerBlock, and for the default FormContainerBlock I would like to exclude my custom elements..
is this possible?

So far I have tried to override and use AllowedTypes for the ElementsArea-property of MyCustomFormContainerBlock, but if I specify my custom elements they dont show up in the UI for some reason (the contentarea doesnt allow the user to pick any elements)


Viewing all articles
Browse latest Browse all 6894

Trending Articles