Yii Framework Forum: fileField problem - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

fileField problem validation error "cannot be blank" Rate Topic: -----

#1 User is offline   rall0r 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 165
  • Joined: 11-November 10
  • Location:Bln

Posted 13 July 2012 - 08:39 AM

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.yiiframew...-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.yiiframew...ad-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
0

#2 User is offline   rall0r 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 165
  • Joined: 11-November 10
  • Location:Bln

Posted 17 July 2012 - 02:30 AM

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/y.../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.
0

#3 User is offline   yugene 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 408
  • Joined: 08-August 09
  • Location:Ukraine

Posted 18 July 2012 - 01:39 AM

Try to use allowEmpty with your file validator
0

#4 User is offline   rall0r 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 165
  • Joined: 11-November 10
  • Location:Bln

Posted 18 July 2012 - 06:09 AM

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
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users