开发者

CJuiautocomplete with multiform model

I am using a multi form model. A $model array is passed 开发者_JAVA技巧to the view and for each model object I am trying to have a text field and it works fine this way. See the code below.

foreach ($model as $f=>$edu):
  echo $form->textField($edu,"[$f]schoolname",array('size'=>30,'maxlength'=>128));

I am trying to have an autocomplete text field coded replacing the activeform text field. It is not working. Any ideas how to make this work.See the code below.

foreach ($model as $f=>$edu):
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
  'model'=>$edu,
     'attribute'=>"[$f]schoolname",
   'source'=>$this->createUrl('AutoComplete/acschoolname'),
     // additional javascript options for the autocomplete plugin
     'options'=>array('showAnim'=>'fold',),
     'htmlOptions'=>array('size'=>'30','maxlength'=>'128',) 
 ));


This appears to be a bug in Yii. Tabular form input is broken with widgets.

A workaround was posted in the Yii forums. I haven't tested it, but it's reported to work:

http://www.yiiframework.com/forum/index.php?/topic/10685-collecting-tabular-input-with-zii-jui-widgets-is-broken/

Baiscally, around Line 82 in CJuiAutoComplete.php, comment out the following lines:

//else
  //$this->htmlOptions['name']=$name;

To make sure you are not modifying the Yii core and breaking upgrades, I would copy CJuiAutoComplete.php in to your /components folder and rename it MyJuiAutoComplete or something, and call that instead of CJuiAutoComplete.

Good luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜