The label 'for' attribute should reflect the id of the labelled control, not the name.
The population of the 'for' attribute for the label has been tied to the name field of the attached control. This has worked fine when using a simple property in the control expression, since the id and name are always equivalent, such as:
However if a complex expression is used, then the input 'id' must be sanitized, and the name must remain unsanitized so that the complex model can be model bound when posted. With the existing code the name is also sanitized, which breaks the default MVC model binding for complex properties.
The label 'for' attribute should reflect the id of the labelled control, not the name.
The population of the 'for' attribute for the label has been tied to the name field of the attached control. This has worked fine when using a simple property in the control expression, since the id and name are always equivalent, such as:
However if a complex expression is used, then the input 'id' must be sanitized, and the
name
must remain unsanitized so that the complex model can be model bound when posted. With the existing code the name is also sanitized, which breaks the default MVC model binding for complex properties.This change implements this correct behaviour for complex properties.