Yii Framework Forum: Wrong documentation for CUploadedFile::getInstance() (Parameter $attribute) - Yii Framework Forum

Jump to content

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

Wrong documentation for CUploadedFile::getInstance() (Parameter $attribute) Rate Topic: -----

#1 User is offline   Coksnuss 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 141
  • Joined: 14-May 09

Posted 11 August 2012 - 02:33 AM

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?!
0

#2 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 11 August 2012 - 07:12 AM

Hello

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

Quote

Maybe this has changed over time?!


[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.yiiframew...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

This post has been edited by bennouna: 11 August 2012 - 07:16 AM

0

#3 User is offline   Coksnuss 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 141
  • Joined: 14-May 09

Posted 11 August 2012 - 08:00 AM

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