Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Hook custom validation error

Hi again Team,

I'm trying to hook custom login validation error. I managed to throw it as new Exception message and it show's on the lower left corner. Can I hook/throw this same error on the login validation (the one with red background wrapped with div.Messages Errors > ul > li)?

I've search hours on this forum, can't find any.



  • Options
    R_JR_J Ex-Fanboy Munich Admin
    edited July 2018

    Hard to tell without any code from you.

    Look at this code, taken from the EntryController:

            if ($this->Form->isPostBack()) {
                $this->Form->validateRule('Email', 'ValidateRequired', sprintf(t('%s is required.'), t(UserModel::signinLabelCode())));
                $this->Form->validateRule('Password', 'ValidateRequired');
                if (!$this->Request->isAuthenticatedPostBack() && !c('Garden.Embed.Allow')) {
                    $this->Form->addError('Please try again.');

    Instead of throwing an error, I would simply "put" it there.

    public function entryController_signIn_handler($sender) {
        if ($sender->Form->isPostBack() == false) {
        // Do the checks with $sender->Form->formValues()
        if ($failed == true) {
            $sender->Form->addError('This should be a meaningful message.', 'Your Additional Field');
  • Options

    Thanks again @R_J , I indeed managed to add custom error using the condition on $sender->Form->formValues().
    You rock!

Sign In or Register to comment.