Closed mludlum closed 7 years ago
Found a way to do this with a display template. Created a template with this code
@ViewData["value"]
Then used this to create the form item
@form.DisplayFor(m => m.MyId, templateName:"DisplayForValue", additionalViewData:new { value="My Alternate Text" })
Great! I'd go ahead and roll with that given it's been a long time since I've looked at this project and probably wouldn't be able to help out for a while.
Thank-you for your work on this project. It was a quick way for me to get my old MVC site responsive. Will you be monitoring Pull Requests?
:thumbsup: Glad you found it useful! I still use it myself on some work projects, I'm just not doing much new with it.
Will you be monitoring Pull Requests?
Yep - if you send one in and it doesn't break any tests, I'll probably merge it and do a release.
I have fields which are IDs to foreign records. I want to use DisplayForwith a hidden field, but I want the display value to be text of my choosing instead of the foreign key integer. Can I do that with DisplayFor without creating a template? Or, is there an easy way to create a template in the context of calling DisplayFor?