Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

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
Labels

Comments

@dpommeranz
Copy link
Contributor

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());                               
}                                                                            
@dpommeranz
Copy link
Contributor Author

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

@steverhoades
Copy link
Contributor

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

@adamlundrigan
Copy link
Contributor

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

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

No branches or pull requests

3 participants