ChameleonForms Breaking Changes
Enums marked with the
[Flags] attribute will now show as multiple select elements (or checkboxes when displaying as a list).
Support has been added for flags enums; these make sense as multiple-select controls since a flags enum can support multiple values.
Create a enum class without the
[Flags] attribute with the same values and bind to that instead.
WithoutLabel method on
IFieldConfiguration. It still works (for now), but the method has been marked with the
The method has been renamed to
WithoutLabelElement since it more closely reflects what the method does.
Change all instances of
ReadOnlyConfiguration public class.
The class was redundant, because it just wrapped calls to
FieldConfiguration instance. Implementing
FieldCofiguration class has more sense
ReadonlyConfiguration class expected not to be widely using. In case of using remove reference to he class and/or move possible implementation to custom wrapper around
TTemplate type parameter from all of the form component classes. This will only affect you if you created custom form components e.g. you extended
It made extensibility harder to have to pass that type around everywhere and it wasn't really being used. Using polymorphism with a property of type
IFormTemplate made more sense.
You need to change any custom components to simply remove the template type. If you custom component relied on that template type for strong typing then you can follow the example of the
RandomComponent example in the source: https://github.com/MRCollective/ChameleonForms/blob/master/ChameleonForms.Example/Forms/Components/RandomComponent.cs.
AsList method on the
IFieldConfiguration interface has been removed in favour of
We feel this is more discoverable and intention revealing than
Change any instances of using
@s.FieldFor(m => m.SomeField).AsList() to
@s.FieldFor(m => m.SomeField).AsRadioList() or
@s.FieldFor(m => m.SomeField).AsCheckboxList().
FieldFor extension method on the Form has been deprecated in favour of a
This fits in more consistently with the nomenclature of ChameleonForms given that the method outputs the Field Element rather than the Field.
Change any instances of using
@f.FieldFor(m => m.SomeField) to
@f.FieldElementFor(m => m.SomeField).
DefaultFormTemplate class has been moved to the
ChameleonForms now has more than one built-in template so it made sense to move them into their own namespaces.
If you referenced the
DefaultFormTemplate at all then you will need to change the using statement from
[ExistsIn] attribute now performs server-side validation by default to ensure the selected value is in the list.
You can opt-out of this validation globally by setting ExistsInAttribute.EnableValidation or per-usage by passing a boolean enableValidation parameter to the ExistsIn attribute.
If you do use validation, the attribute requires that the list is populated at validation time in the ASP.NET MVC pipeline. This requires you to either fill the list in the constructor of your view model or to create a model binder to populate the list.
If you don't populate the list before the validator runs then ExistsIn will throw an exception on trying to validate - you should either populate the list or disable validation to resolve this.
We wanted to provide in-built server-side validation of fields using the
[ExistsIn] attribute and the easiest way to do that is to hook into the validation pipeline in ASP.NET MVC.
If for some reason you don't want server-side validation to run then don't populate your list until after the validation pipeline runs. If you need to be able to opt out of validation, but still populate the list before then or to tweak the validation in some other way then raise an issue so we can add that functionality.
The submit/reset/button methods in Navigation now chain
HtmlAttributes methods off the end rather than taking them as a parameter.
This provides a much nicer experience when using these methods in your view - you don't have to new up a
HtmlAttributes object anymore.
If you are using the old methods then change your
HtmlAttributes object to use the same parameters that were in there, but by chaining method calls off of the end of the method.
@n.Submit("Submit", new HtmlAttributes().AddClass("btn"))
If you were passing in the
HtmlAttributes object to the view rather than generating it inline then use