Yii Framework Forum: Gathering Tabular Input - Property "Item." is not defined. - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Gathering Tabular Input - Property "Item." is not defined. Rate Topic: -----

#1 User is offline   Arvind 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 03-October 09
  • Location:Calgary, AB, Canada

Posted 24 October 2009 - 06:52 PM

Hello,

I have been trying to gather tabular input. The idea is for me to insert around 6 or 7 records.

i am using this as my guide
http://www.yiiframew...uide/form.table

I keep getting the error..
Property "Item." is not defined.


this error is from the line
<? echo CHtml::activeTextField($item,"[$i]count"); ?>



Can anybody guide me please ?

thanks
Arvind
0

#2 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,651
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 24 October 2009 - 07:43 PM

Works for me!

You are on 1.1a, right? Syntax change, [$i]attr instead of attr[$i].
Also check that the attribute 'count' exists and has the correct case.

/Tommy
Don't forget to read The Definitive Guide to Yii (en) (sv) | The class reference has the details
0

#3 User is offline   Arvind 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 03-October 09
  • Location:Calgary, AB, Canada

Posted 24 October 2009 - 07:59 PM

View Posttri, on 24 October 2009 - 07:43 PM, said:

Works for me!

You are on 1.1a, right? Syntax change, [$i]attr instead of attr[$i].
Also check that the attribute 'count' exists and has the correct case.

/Tommy


No, i am on 1.0.10. actually the attribute is TIMESPENT. and it still complains with that same error.

I managed a hack in this way. Let me know if this is not good.

echo CHtml::activeTextField($item,"TIMESPENT",array('name'=>'LifeProfile['.$item->ACTIVITYID.'][TIMESPENT]') ;


thanks
Arvind
0

#4 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,651
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 24 October 2009 - 08:33 PM

Here is an excerpt from the 1.0.10 guide, the section on tabular input
<div class="yiiForm">
<?php echo CHtml::beginForm(); ?>
<table>
<tr><th>Name</th><th>Price</th><th>Count</th><th>Description</th></tr>
<?php foreach($items as $i=>$item): ?>
<tr>
<td><?php echo CHtml::activeTextField($item,"name[$i]"); ?></td>
<td><?php echo CHtml::activeTextField($item,"price[$i]"); ?></td>
<td><?php echo CHtml::activeTextField($item,"count[$i]"); ?></td>
<td><?php echo CHtml::activeTextArea($item,"description[$i]"); ?></td>
</tr>
<?php endforeach; ?>
</table>


Older versions of the pdf guide are available to download
http://www.yiiframew...s-1.0.10.tar.gz
http://www.yiiframew...docs-1.0.10.zip

/Tommy
Don't forget to read The Definitive Guide to Yii (en) (sv) | The class reference has the details
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

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