FileExtension validor error in Form context #3389

Closed
neilime opened this Issue Jan 9, 2013 · 3 comments

4 participants

@neilime

Error append when validating a form wich contains Zend\Form\Element\File with File\Extension validator.

$form = new \Zend\Form\Form();
  $form->add(array(
    'name' => 'test_file_input',
    'type'  => 'Zend\Form\Element\File'
));

$inputFilter = new \Zend\InputFilter\InputFilter();
$inputFilter->add(array(
'name' => 'test_file_input',
'required' => true,
'validators' => array(
    array(
      'name' => 'File\Extension',
      'options' => array('extension' => 'mo')
  )
)
));
$form->setInputFilter($inputFilter);

//Fake datas for test
$_FILES = array(
    'test_file_input' => array(
    'name'  => 'testsize.mo',
        'type'   => 'text',
        'size'   => 200,
        'tmp_name' => '/home/tmp/phpZiL4GG',
        'error' => 0
    )
);

$form->setData($_FILES)
$form->isValid(); // Error : stream_resolve_include_path() expects parameter 1 to be string, array given
@weierophinney
Zend Framework member

Which branch does this occur against -- master or develop? If master, can you please test against develop, as there have been a number of changes there in the past month? If it's against develop, I'll see what I can do.

@cgmartin

Using the develop branch, you likely need to ensure that you are using type Zend\InputFilter\FileInput for your 'test_file_input' input specification. It is required for the file input filters/validators to work.

$inputFilter->add(array(
'name' => 'test_file_input',
'type'     => 'Zend\InputFilter\FileInput',
...
));

@neilime let me know if that doesn't fix it - I'll try to help and reproduce on my end.

@neilime

Yes it works with the develop branch.

@Maks3w Maks3w closed this Jan 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment