November Happy Hour will be moved to Thursday December 5th.

Episerver.Forms - add a css class to a form field

Vote:
 

Hello,

I created a form using episerver. forms. I would like to add a css class to a form field. Anyone knows how can I do that?

Thanks in advance,

Rita

#147552
Apr 18, 2016 14:28
Vote:
 

Rita,

Have you read this?  http://webhelp.episerver.com/latest/cms-edit/using-forms.htm > Creating a form > 2. Adding form fields ?

#147563
Edited, Apr 18, 2016 18:36
Vote:
 
<p>Depending on which field type you want to add your css class to, you'll need to copy its view from the folder modules\_protected\EPiServer.Forms\Views\ElementBlocks</p> <p>to ~/Views/Shared/ElementBlocks and make your customization on the markup.</p> <p>Have a look at my blog post where I mention the basics of extending forms:&nbsp;<a href="https://talk.alfnilsson.se/2016/02/15/tweaking-and-extending-episerver-forms-part-2/">https://talk.alfnilsson.se/2016/02/15/tweaking-and-extending-episerver-forms-part-2/</a></p>
#147564
Apr 18, 2016 19:23
Vote:
 

Thanks Alf Nilsson,

I did exactly what you said, I copied TextboxElementBlock.ascx from modules\_protected\EPiServer.Forms\Views\ElementBlocks to ~/Views/Shared/ElementBlocks, exactly with the same name and then I added one text element to my form but I don't see my changes. it seems my new view is being ignored.

I also checked Forms.config and seems ok. 

<episerverforms minimumAccessRightLevelToReadFormData="Edit"
sendMessageInHTMLFormat="true"
defaultUploadExtensionBlackList="asp,aspx,asa,ashx,asmx,bat,chm,class,cmd,com,config,dll,exe,hta,htr,htw,jse,json,lnk,mda,mdb,msc,msh,pif,printer,ps1,ps2,reg,rem,scf,scr,sct,shtm,shtml,soap,stm,svc,url,vb,vbe,vbs,vsix,ws,wsc,wsf,wsh,xamlx,htm,html,js,jar"
coreController="/EPiServer.Forms/DataSubmit"
formElementViewsFolder="~/Views/Shared/ElementBlocks"
workInNonJSMode="false"
injectFormOwnJQuery="true">

#147589
Apr 19, 2016 13:51
Vote:
 

Hi Again,

I don't know what changed but I had to close my Visual Studio and when I opened again it starts working.

Thanks a lot. Your blog is really helpfull.

Rita

#147592
Apr 19, 2016 14:19
Vote:
 

It's not about Visual Studio.

ASP.NET try to find the view from 

  • formElementViewsFolder="~/Views/Shared/ElementBlocks"
  • then from modules\_protected\EPiServer.Forms\Views\ElementBlocks
  • Once it found the view, it will never do finding again (kind of caching). All you need to do is restart your website/rebuild your project to start the ASP.NET application again.
#148288
May 09, 2016 13:24
Vote:
 

We ran into an issue where in our production domain formElementViewsFolder="~/Views/Shared/ElementBlocks" is not being honored. We have restarted the website multiple times. It works on our internal site but not on our public facing site. modules\_protected\EPiServer.Forms\Views\ElementBlocks has no views in it and only ~/Views/Shared/ElementBlocks has the views.

#248546
Edited, Feb 12, 2021 17:07
* 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.