fileField problem

Hi,

since 2 days I’m working at the same problem and finally i think this could be an bug.

I try to render an view, with 2 CActvieForm Widgets. One of the widget contains an fileField to upload a file.

I use this example to build the code:

http://www.yiiframework.com/wiki/2/how-to-upload-a-file-using-a-model/

The Point is: if i upload an file using the CActiveFrom with an ajaxSubmitButton, than the validation says:

"Z cannot be blank" (where Z is the Attribute).

This is correct, because if i look at firebug, is see nothing is transmitted to the action. (The variable myModel[Z] is empty). But ifI use the same form with an textField instead an fileFilde, then everything works fine.

Next step:

After reading this post (where an user has the same problem)…

http://www.yiiframework.com/forum/index.php/topic/22566-cant-get-upload-file-working

…I use renderPartial instead of render and: everything works, also uploading an file.

So i decided to use renderPartial to render the form, followed by an render for the rest of the layout, like this.


		$this->renderPartial('_index_uploadForm',array(

				'myModel'=>$myModel

		));

		$this->render('_index',array(

		));

Now, upload does not work, the uploaded file is not part of the post request (myModel[Z] is empty again)

Finlay i tried to renderPartial the uplaodForm AND renderPartial the rest of the layout:


		$this->renderPartial('_index_uploadForm',array(

				'modelUpload'=>$modelUpload

		));

		$this->renderPartial('_index',array(

		));

…the upload works, but the application/webpage Layout is not complete (because render() is never used)

Does anyone has an idea what happened here?

Thank you, rall0r

Does nobody has an idea?

So it looks like, i should open an new bug issue.

But if i look at this: https://github.com/yiisoft/yii/issues/new

I need to log into gut hub, but i don’t have an github - account.

Is there an alternative way to post an bug or could somebody pleas open an issue for me?

Thank you.

Try to use allowEmpty with your file validator

Hi yugene,

the point is, that the uploaded document is not transmitted to the server.

In fact: no upload happend.

The result is: the Variables in $_POST are empty which causes in an validation error. Setting the validator to allowEmpty will is not helpful, because is not the goal to validate by excepting non valid inputs (empty ones).

greetings rall0r