I am implementing Autocomplete in a form using jQuery. The plugin displays selected value with , separator.
I also need it's respective fetched id from database in comma separator. Instead the lated value override the previous one.
I tried to use push operation couldn't.
- <?php $this->widget('CAutoComplete',
- array(
- //name of the html field that will be generated
- 'name'=>'user_name[]',
- //replace controller/action with real ids
- 'url'=>array('Privacy/autoCompleteLookup'),
- 'max'=>10, //specifies the max number of items to display
-
- //specifies the number of chars that must be entered
- //before autocomplete initiates a lookup
- 'minChars'=>1,
- 'delay'=>200, //number of milliseconds before lookup occurs
- 'matchCase'=>false, //match case when performing a lookup?
-
- //any additional html attributes that go inside of
- //the input field can be defined here
- 'htmlOptions'=>array('size'=>'40'),
-
- 'methodChain'=>".result(function(event,item){\$(\"#allow\").val(item[1]); \$(\"#allow\").prepend($(20));})",
- 'multiple' => true,
- ));
- ?>
- <?php echo CHtml::hiddenField('allow'); ?> // its equivalent html form is : <input type="hidden" name="allow" >
jQuery part is in
line number 20 and the record's is should be in
hidden form line number 24
Thank you for your support.