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

Vote:
 

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)

#216573
Edited, Feb 10, 2020 10:20
Vote:
 

Basically, the form elements widget will list all element which are inherited from ElementBlockBase. For custom its behavour, you could override the ContentTypeService.js in FormsUI module, for insert/remove element types you want to display.

#216991
Feb 12, 2020 7:30
Vote:
 

Could you please "pinpoint" me to where in ContentTypeService.js I would modify this?

Cant this be done by overriding anything on the .Net-side of EPiServer? I assume that ContentTypeService somehow communicates with the backend to get the valid ElementBlocks (or maybe just any block which is then filtered by the ContentTypeService), if this is the case.. then I guess I should be able to override whatever returns the result to ContentTypeService.js.. any ideas?

#216993
Edited, Feb 12, 2020 9:04
* 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.