Wrong documentation for CUploadedFile::getInstance() (Parameter $attribute)

Hey folks,

in the documentation for the method CUploadedFile::getInstance() it states:


$attribute string the attribute name. For tabular file uploading, this can be in

the format of "[$i]attributeName", where $i stands for an integer index.

In fact i need to type attributeName[$i] to get this working. Maybe this has changed over time?!

Hello

What do you get working when you type attributeName[$i]?

[Edit: Maybe :) I have been using Yii since 1.1.8 only. Since then:]

An easy way to check what goes on is to compare the file input’s name and id that are output in your HTML code by Yii.

Another way is to check the source code of the method that is called in "the background": CUploadedFile::getInstance() calls in fact CHtml::resolveName()

So you can see there’s a difference between:

  • [$i]attribute that generates names like Model[5][attribute] -> that is useful for tabular input : see here : http://www.yiiframework.com/doc/guide/1.1/en/form.table

  • attribute[$i] that generates names like Model[attribute][5] -> that should not be very useful natively with Yii

Hope it helps :)

Second Edit:

Ok, I’ve just though to compare with Yii 1.0 doc and it says to use attribute[$i] so I think the mystery is solved :D

Thanks for your reply bennouna. I am using Yii 1.1.11. Specifically i am using the CMultiFileUpload widget which generates an input field as follows:


<input id="UploadForm_files" type="file" value="" name="UploadForm[files][]" />

As there are no other attributes/models other than that i am not running into problems with this convention.

But as you pointed out the current convention is the other way around. Maybe this could be pointed out in the documentation as well :)