8000 [Form] Add support for Validation Group Sequences without using entities · Issue #5665 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] Add support for Validation Group Sequences without using entities #5665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
simshaun opened this issue Oct 4, 2012 · 8 comments
Closed

Comments

@simshaun
Copy link
Contributor
simshaun commented Oct 4, 2012

Recently found out about validation group sequences from #2947.

I'm fairly convinced after looking through the form component that it does not support them if you are adding constraints within the form type, and have no entity with which to apply the sequence.

The purpose of this feature request is to add support for validation group sequences in the form component.

@ghost
Copy link
ghost commented Jan 18, 2013

Up

@ghost
Copy link
ghost commented Jan 22, 2013

Is there any estimated time when someone will start to work on this feature? It is hard to do that?
(I'm just waiting for some weeks and if this will not be done soon, I will try to find another way, and when this will come out I will change my code and use it. Or I will try to add this feature by myself and if will done, will make a pull request)

@ghost
Copy link
ghost commented Jan 30, 2013

Finally I found a solution for my problem:

class MyCustomConstraintValidator extends ConstraintValidator
{
    public function validate($value, Constraint $constraint)
    {
        $has_violation = false;
        foreach ($this->context->getViolations()->getIterator() as $violation) {
            if ($violation->getPropertyPath() == $this->context->getPropertyPath()) {
                $has_violation = true;
                break;
            }
        }

        if (!$has_violation) {
            $this->context->addViolation($constraint->message, array('%string%' => $value));
        }
    }
}

@ghost
Copy link
ghost commented Feb 2, 2013

This method is very useful for me. Maybe make a pull request?

@ghost
Copy link
ghost commented Feb 17, 2013

Ok, no one cares. Just made myself an alternative class ContraintValidator and will use it instead

@webmozart
Copy link
Contributor

Hi @moldcraft, thank you for your commitment and your patience on this issue. I opened a new related ticket #7146. In addition to that ticket, the Form component should support GroupSequence instances in the validation_groups option (also for custom constraints):

$form = $factory->create('myform', null, array(
    'constraints' => array(...),
    'validation_groups' => new GroupSequence(array('first', 'second')),
));

I'll leave this ticket open as feature request, but I cannot give an estimation yet on when this will be implemented.

@patie
Copy link
Contributor
patie commented Dec 19, 2013

something new with this ?

@webmozart
Copy link
Contributor

This should be possible since #10287.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
0