This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » plugins » Javascript plugins » Invalid argument in supplied for foreach().. : in sfWidgetFormJQueryAutocompleterMany.class
Invalid argument in supplied for foreach().. : in sfWidgetFormJQueryAutocompleterMany.class [message #97409] Thu, 15 April 2010 04:41
aszrool  is currently offline aszrool
Messages: 8
Registered: March 2010
Junior Member
I had followed the guide in http://forum.symfony-project.org/index.php/m/78548/ and code snippet in http://snippets.symfony-project.org/snippet/336 for autocomplete in sfFormExtraPlugin. Everything run smoothly but only in my form, I got this error messages.
Warning: Invalid argument supplied for foreach() in C:\www\sfprojects\invy\plugins\sfFormExtraPlugin\lib\widget\sfWidgetFormJQueryAutocompleterMany.class.php on line 106


This is my code..

form code
	 $autocompleteWidget = new sfWidgetFormChoice(array(
	   'multiple'         => true,
	   'choices'          => $this->getObject()->getItemId(),
	   'renderer_class'   => 'sfWidgetFormJQueryAutocompleterMany',
	   'renderer_options' => array(
	     'config' => '{
		    json_url: " '.sfContext::getInstance()->getController()->genUrl('item/autocomplete').'",
			json_cache: true,
			filter_hide: true,
			filter_selected: true,
			maxshownitems: 8
	     }')
	 ));
	 $this->widgetSchema['item_id'] = $autocompleteWidget;


class code
   static public function retrieveSuggestions($q, $l, $c)
   {
     $itemid = Doctrine_Query::create()
	   ->select('t.*, LOCATE(:token_raw, t.name) AS index')
	   ->from('InvyItemRegistry t')
	   ->where('t.name LIKE :token')
	   ->orderBy('index')
	   ->limit($l)
	   ->execute(array('token_raw' => $q, 'token' => '%'.$q.'%'));
	   
	   $jsonItems = array();
	   foreach ($itemid as $item)
	   {
	      $jsonItems[] = array('caption' => (string)$item->getName(), 'value' => $item->getPrimaryKey());
	   }
	   return $jsonItems;
   }


action code
 public function executeAutocomplete(sfWebRequest $request)
   {
      $this->getResponse()->setHttpHeader('Content-Type', 'application/json; charset=utf-8');
	  
	  $items = InvyItemRegistry::retrieveSuggestions($request->getParameter('q'), $request->getParameter('l'), $request->getParameter('c'));
	  
	  return $this->renderText(json_encode($items));
   }


What am I suppose to do?

[Updated on: Thu, 15 April 2010 04:44]

Previous Topic:jQueryUI Tabs issue
Next Topic:sfJqueryReloadedPlugin jq_link_to_remote question
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software