tags:

views:

441

answers:

1

I think I found a weird problem in Symfony.

Here's my upload case form:

<?php

class UploadCaseForm extends sfForm {
    public function configure()
     {
     $this->setWidgets ( array ('Documents' => new sfWidgetFormInputFile ( ) ));
        $this->widgetSchema->setNameFormat('UploadCase[%s]');
     $this->setValidators(array(
     'Documents'=>new sfValidatorFile ()
     ));



    }
}
?>

And the action class is this:

public function executeIndex(sfWebRequest $request) {

 if ($this->getRequest ()->getMethod () == sfRequest::GET) {
  $this->form = new UploadCaseForm ( );
 } else if ($this->getRequest ()->getMethod () == sfRequest::POST) {
  $this->form->bind ($request->getParameters('UploadCase'), $request->getFiles ( 'UploadCase' ) );


 }

}

I would expect that after I upload a file, $request->getParameter('UploadCase') should return a NULL, but not crashing the web application. Instead the web app crashed.

Anything that I do wrong?

A: 

This is a bug, I think. The bug is because $request->getParameter('UploadCase') has only 1 file upload, no other fields. So the below statement will return null.

($request->getParameter('UploadCase'));

And this will cause the statement

$this->form->bind ($request->getParameters('UploadCase'), $request->getFiles ( 'UploadCase' ) );

to crash like there is no tomorrow.

Ngu Soon Hui