INightmare's Blog

Modifying Lift error message style

Modifying Lift error message style

There is how you can change default message styles for forms generated by LiftScreen or Wizard.

The validation message styles are defined in LiftScreenRules.messageStyles.

LiftScreenRules.messageStyles.default.set(
  (() => {
    case NoticeType.Notice => new UnprefixedAttribute("class", "lift-notice", Null) // We leave the default
    case NoticeType.Warning => new UnprefixedAttribute("class", "lift-warning", Null) // Also the default
    case NoticeType.Error => New UnprefixedAttribute("class", "custom-error", Null) // We change the class, as default is lift_error
  }: PartialFunction[NoticeType.Value, MetaData]))
)

You can also have these set based on request or session parameters, by setting LiftScreenRules.messageStyles.request or LiftScreenRules.messageStyles.session.