We have just started working on a project using DevForce and one of the things we wish to do is highlight which fields are required to the user on creating a new record.
The issue we are running in to is that DevForce seems to initialize nullable fields to the default for their type and, as such, the UI does not show the highlights etc on the required fields unless we specifically go and null out the properties that we wish to highlight to the user.
private void InitializeUser()
{
_creatingUser = Manager.Users.FirstOrDefault(u => u.UserName ==
Manager.AuthenticationContext.Principal.Identity
.Name);
var zone = DateTimeZoneProviders.Tzdb.GetSystemDefault();
Instant systemTime = SystemClock.Instance.Now;
// HACK: nulling out strings to make the validation fire correctly
// need to find a beter solution for this
UserToAdd = new User()
{
CreatedBy = _creatingUser,
CreatedDate = systemTime.InUtc().ToDateTimeUtc(),
CreatedTz = zone.Id,
ModifiedBy = _creatingUser,
ModifiedDate = systemTime.InUtc().ToDateTimeUtc(),
ModifiedTz = zone.Id,
UserName = null,
Email = null,
FirstName = null,
LastName = null,
Active = true
};
}
We didn't see an option to disable this initialization and we are wondering if any fellow Stackoverflowers have ran into this issue and found a better solution.
The easiest way to set model-wide defaults is to use a DefaultValueFunction
, which you can read more about on the DevForce Resource Center.