Okay so I have an out standing pull request to add support in for Closures

https://github.com/symfony/symfony/pull/868

This means I can add in dynamic validation on a form via a Closure easily.

The reason I started down this line is because of these lines of code:

$formBuilder->setAttribute('validation_constraint', new
Callback(array("methods"=>array(
    'validate' => function ($data, $context) use ($elements) {
       // logic to add violations depending on the elements
        foreach($elements as $hash => $element) {
            $constraints = $element->getConstraints();
            foreach($constraints as $constraint) {

$context->getGraphWalker()->walkConstraint($constraint,
(isset($data[$hash]))?$data[$hash]:'', array(),
'children['.$hash.']');
            }
        }
    }
))));

The reason for this post is the 'children['.$hash.']' on the
walkConstraint. Initially I just put in the $hash variable but the
errors appeared in the global errors not next to the field. In this
code case the var $hash is the name of the field in the form.

I debugged a standard form to see what value it was using for
propertyPath and discovered two uses.

1)  'children['.$hash.']'
2)  'data'.$hash

I am a little worried about hard coding this children string and if I
should be using the data string? Anyone know anything about this at
all?

Cheers
John

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to