senad87
(Senadstore)
March 15, 2012, 4:01pm
1
Hello,
is there a way to set success message for axaj validation in model?
Just like addError() sets the error message with the css class ‘errorMessage’.
Now I am setting success messages like this:
$this->addError(‘email’, ‘<span class=“success”>User with that email address already exist</span>’);
but this looks "ugly".
Thank you in advance.
bettor
(Live Webscore)
March 15, 2012, 4:33pm
2
senad87
(Senadstore)
March 16, 2012, 11:23am
3
Thanks, but that is not what I need. I’ll explain better.
I’ve created registration form with fields nickname, email etc.
Fields are validated when user clicks to next field and if, for instance,
user with same nickname exists addError() is triggered and displays error text right next to the field "User already exists".
What I need at that point is:
if user does not exist and nickaname is available, to show appropriate message
but I don’t want to use addError() method.
I hope that was clear enough
abennouna
(Abennouna)
March 16, 2012, 11:50am
4
So you mean something like
$this->addError('email', '<span class="success">User is available</span>');
If it looks ugly, why don’t you style it (CSS) to fit your needs? You can style both this span (you add [color="#000080 "][font=“Courier New”]div.form .errorMessage .success[/font][/color]) and the input field (you customize or override [color="#000080 "][font=“Courier New”]div.form div.success input, div.form div.success textarea, div.form div.success select, div.form input.success, div.form textarea.success, div.form select.success[/font][/color] in form.css (line 109))
Edit : But it should prevent the form validation at all… So maybe you should just add your own method addSuccess?
See also: http://www.yiiframework.com/forum/index.php?/topic/24722-field-validated-display-success-message/
senad87
(Senadstore)
March 16, 2012, 11:57am
5
So you mean something like
$this->addError('email', '<span class="success">User is available</span>');
If it looks ugly, why don’t you style it (CSS) to fit your needs? You can style both this span (you add [color="#000080 "][font=“Courier New”]div.form .errorMessage .success[/font][/color]) and the input field (you customize or override [color="#000080 "][font=“Courier New”]div.form div.success input, div.form div.success textarea, div.form div.success select, div.form input.success, div.form textarea.success, div.form select.success[/font][/color] in form.css (line 109))
Yes
and didn’t mean ugly like that
I think it’s “ugly” to have method named addError to displays success messages, that’s all.
And it may be confusing for other developers.
Thank you for quick reply.