Yii Framework Forum: Unbound error messages in models - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Unbound error messages in models Rate Topic: -----

#1 User is offline   soso 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 24-February 10

Posted 14 May 2010 - 08:18 AM

I have a form model, a login form, with username & password. When the username/password is wrong I'd like to attach an error like "Incorrect user or password" to the model but addError/s only allows error messages that are bound to a field and in this case it doesn't make sense to bound the error to either username or password.
Looking inside the code I don't see any possibility to add unbound error messages. Anyone else felt the need of such error messages?

Thanks,
-soso
0

#2 User is offline   lucifurious 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 184
  • Joined: 15-March 09
  • Location:Atlanta, GA.

Posted 14 May 2010 - 09:15 AM

View Postsoso, on 14 May 2010 - 08:18 AM, said:

I have a form model, a login form, with username & password. When the username/password is wrong I'd like to attach an error like "Incorrect user or password" to the model but addError/s only allows error messages that are bound to a field and in this case it doesn't make sense to bound the error to either username or password.
Looking inside the code I don't see any possibility to add unbound error messages. Anyone else felt the need of such error messages?

Thanks,
-soso


Easy peasy. Just pass a blank string as the first argument:

$model->addError('','Invalid user name and/or password');
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users