form validation fails on dyamic collections if the input filter is "generated" before the data is set #5243

Closed
dpommeranz opened this Issue Oct 8, 2013 · 3 comments

Comments

Projects
None yet
3 participants
Contributor

dpommeranz commented Oct 8, 2013

this error occurs for example if you use the fileprg plugin and add a new item to the collection. the fileprg alters the "generated" input filter (FilePostRedirectGet.php line 67) and sets the data afterwards.

public function testCanCallGetInputFilterBeforeSetDataWithDynamicCollection()
{                                                                            
    $dataWithCollection = array(                                             
        'foo' => 'bar',                                                      
        'categories' => array(                                               
            0 => array('name' => 'cat1'),                                    
            1 => array('name' => 'cat2'),                                    
        ),                                                                   
    );                                                                       
    $this->populateForm();                                                   
    $this->form->add(array(                                                  
        'type' => 'Zend\Form\Element\Collection',                            
        'name' => 'categories',                                              
        'options' => array(                                                  
            'count' => 1,                                                    
            'allow_add' => true,                                             
            'target_element' => array(                                       
                'type' => 'ZendTest\Form\TestAsset\CategoryFieldset'         
            )                                                                
        )                                                                    
    ));                                                                      
    $this->form->setValidationGroup(array(                                   
        'foo',                                                               
        'categories' => array(                                               
            'name'                                                           
        )                                                                    
    ));                                                                      
    $this->form->getInputFilter();                                           
    $this->form->setData($dataWithCollection);                               
    $this->assertTrue($this->form->isValid());                               
}                                                                            
Contributor

dpommeranz commented Oct 18, 2013

@steverhoades Could you add the test case into your branch and tell me if it fixes the issue? That would be great ;)

Contributor

steverhoades commented Oct 18, 2013

@dpommeranz ok, it does not resolve your issue. I am looking into it, perhaps I can include it in my PR.

Member

adamlundrigan commented Oct 21, 2015

The provided test passes against Zend\Form master. I'd guess it's been fixed since?

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