Form validation for field not possible #11135

Closed
KennethVeipert opened this Issue Nov 14, 2015 · 1 comment

Projects

None yet

2 participants

@KennethVeipert

Hi!
If i try to get the messages for a single field i get nothing, but if i get the messages of the form for the field with "$form->getMessagesFor('xyz')" it works correctly.

Code to reproduce:

// Form field
            $element = $this->add(new Element\Mail('mail'));
            $element->addValidator(
                new Validator\PresenceOf(array(
                    'message' => $this->getDi()->get('translator')->query('front.form.error.PresenceOf'),
                ))
            );

// Controller for example
            $mail = $form->get('mail');
            echo '<pre>';
            var_dump($mail->getMessages()); // Wrong - No messages
            var_dump($form->getMessagesFor('mail')); // Correct - PresenceOf Message
            echo '</pre>';
@mbrostami mbrostami referenced this issue Dec 9, 2016
Merged

Form validation some fixes #12466

3 of 3 tasks complete
@sergeyklay sergeyklay added this to the 3.0.3 milestone Dec 20, 2016
@sergeyklay
Collaborator

Fixed in the 3.0.x branch. Thanks you

@sergeyklay sergeyklay closed this Dec 20, 2016
@sergeyklay sergeyklay self-assigned this Dec 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment