daveaglick / FluentBootstrap

Provides extensions, helper classes, model binding, and other goodies to help you use the Bootstrap CSS framework from .NET code.
http://www.fluentbootstrap.com
MIT License
200 stars 76 forks source link

Alternate value for DisplayFor? #77

Closed mludlum closed 7 years ago

mludlum commented 7 years ago

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?

mludlum commented 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" })

daveaglick commented 7 years ago

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.

mludlum commented 7 years ago

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?

daveaglick commented 7 years ago

: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.