4

We are using Sitecore 8.2 Update 2 along with WFFM 8.2 to render an MVC form on a page. Setting the form type to 'Inline' makes the Title of the field (as set in the form designer) to be displayed as placeholder text. This works perfectly for all fields except for Multiple Line Text Field, where no placeholder attribute is added.

We tried modifying the MultipleLineTextField.cshtml file but I am unable to get the field title there.

Is there a way to add title as placeholder text by modifying any of the WFFM views for Multi Line text Field?

1

Based upon https://stackoverflow.com/questions/15021268/mvc-helper-textarea-placeholder-not-displaying I would assume you should alter (in MultipleLineTextField.cshtml):

@Html.TextAreaFor(x => Model.Value, Model.Rows, Model.Columns, new { @class = "form-control"}) 

into

@Html.TextAreaFor(x => Model.Value, Model.Rows, Model.Columns, new { @class = "form-control", @placeholder = (Model.FormType == Sitecore.WFFM.Abstractions.Data.Enums.FormType.Inline) ? Model.Title : string.Empty })

Just tested it (on latest version) and it seems to work...

  • is it a good practice to edit the already existing basic templates? – orangespark Jan 10 '18 at 12:08
  • In theory not - but in practice it is sometimes the only solution. Even SC support will patch some issues this way. – Gatogordo Jan 10 '18 at 12:21
  • so wouldnt it be better to create custom templates and controls rather than this method. becoz in sitecore we have that liberty right?. – orangespark Jan 11 '18 at 4:31
  • If you think that's better, make it an answer.. but I don't think creating a custom field just for this (which is probably a bug anyway) would be beneficiary – Gatogordo Jan 11 '18 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.