[symfony-users] [Beta4] Handle file upload with array data

2011-06-15 Thread dbenjamin
Hi,

I'm trying to handle multiple file uploads with a binded array.

// FilesType
$builder
-add('photo1', 'file', array(type' = 'file'))
-add('photo2', 'file', array('type' = 'file'))
-add('photo3', 'file', array('type' = 'file'))
;

// controller
$files = array(
'photo1' = null,
'photo2' = null,
'photo3' = null,
);

$form = $this-createForm(new FilesType(), $files);
if ('POST' == $request-getMethod()) {
$form-bindRequest($request);  // Throws an error
}

This actually throws an error from DataTransformer : The key file should 
be empty or instance of File

That should work, no ? I'm not sure what i'm doing wrong.

Any idea ?


Thanks,
Benjamin.

-- 
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


Re: [symfony-users] [Beta4] Handle file upload with array data

2011-06-15 Thread Fabien Potencier

On 6/15/11 12:29 PM, dbenjamin wrote:

Hi,

I'm trying to handle multiple file uploads with a binded array.

// FilesType
$builder
-add('photo1', 'file', array(type' = 'file'))
-add('photo2', 'file', array('type' = 'file'))
-add('photo3', 'file', array('type' = 'file'))
;

// controller
$files = array(
'photo1' = null,
'photo2' = null,
'photo3' = null,
);

$form = $this-createForm(new FilesType(), $files);
if ('POST' == $request-getMethod()) {
$form-bindRequest($request); // Throws an error
}

This actually throws an error from DataTransformer : The key file
should be empty or instance of File

That should work, no ? I'm not sure what i'm doing wrong.

Any idea ?


As we have refactored uploading a lot recently, can you try with the 
latest version of master?


Thanks,
Fabien



Thanks,
Benjamin.

--
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


--
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