PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, January 30, 2022

[FIXED] CJuiautocomplete with multiform model

 January 30, 2022     autocomplete, php, yii     No comments   

Issue

I am using a multi form model. A $model array is passed 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',) 
 ));


Solution

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!



Answered By - thaddeusmt
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing