fubumvc

How can I use Fubu's DisplayConversionRegistry to convert values differently for Edit vs. DisplayFor?


I'm using my own DisplayConversionRegistry descendant to convert values for display in FubuMVC. This works great for date format consistency and the like. However, I find myself trying to format/convert some types of values differently when output in my views via Edit vs. DisplayFor.

For example, I want to display Money values with the currency symbol when output with DisplayFor. However, I do not want the currency symbol output when I use Edit. I also have other scenarios where I need differently formatted values for display than for editors.

Is there a way to do this with DisplayConversionRegistry, or am I missing something else?


Solution

  • As far as I know, you have to introduce a separated convention for Editors to override what you have configured in your DisplayConversionRegistry implementation. You could do this in two ways:

    1. Adding the expression right into your FubuRegistry class (useful for one-offs): https://gist.github.com/3741460

    2. Supply your own HtmlConventionRegistry class and register it into your FubuRegistry (useful if you already have a HtmlConventionRegistry implementor in your codebase): https://gist.github.com/3741471