This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

autocomplete doesn't work

Forum to discuss ExtJS and other JS plugins

autocomplete doesn't work

by aszrool » Mon Apr 19, 2010 2:55 am

I am using sfFormExtraPlugin which is using sfWidgetFormJQueryAutocompleter and used the tips on http://symfonyguide.wordpress.com/2009/08/05/lautocompletion -sur-un-input-text-du-backend/ ... I am also had tried another way in other sources.

Unfortunately, when I tried to input whatever words, the input text field shows the loading animation without any words suggestion appear. Is there any solution I can get? Or can tell me what am I mistakes?
aszrool
Junior Member
 
Posts: 8
Joined: Mon Mar 01, 2010 9:53 am

Re: autocomplete doesn't work

by peerffm » Sat Apr 24, 2010 4:17 pm

it should work.


Form
Code: Select all
class AutoCompleteForm extends sfForm

{
  public function configure()
  {
 
    $this->setWidgets(array(
      ''   => new sfWidgetFormJQueryAutocompleter(array('url' => 'controller/action'))
    ));
   
  }
 
}


controller
Code: Select all
 $this->getResponse()->setContentType('application/json');

 
     $criteria = new Criteria();
     $criteria->add(youModel::NAME, "%".$request->getParameter('q')."%" , Criteria::LIKE);

 foreach (youModel::doSelect($criteria) as $ret)
    {
      $result [$ret->getID()] = (string) $ret;
    }
   
    $this->renderText(json_encode($result));
    return sfView::NONE;


controller action index
Code: Select all
$this->Autocomplete=new AutocompletetForm();


View

Code: Select all
<?php echo $Autocomplete; ?>

peerffm
Junior Member
 
Posts: 18
Joined: Thu Feb 04, 2010 9:28 am
Location: China

Re: autocomplete doesn't work

by peerffm » Sat Apr 24, 2010 4:23 pm

try this and look what firebug say.
peerffm
Junior Member
 
Posts: 18
Joined: Thu Feb 04, 2010 9:28 am
Location: China

Re: autocomplete doesn't work

by allel » Tue Jun 15, 2010 11:55 am

Hello
i had the same problem but i have resolved after reading your code THANKS, but now i have another problem, i would insert three sfWidgetFormJQueryAutocompleter
only one works

first form
Code: Select all
<?php
class SymptomeSearchForm extends sfForm
{
   public function configure()
   {         
      $this->setWidgets(array(
      ''   => new sfWidgetFormJQueryAutocompleter(array('url' => 'BaseDeConnaissance/symptome'))  ));
   }   
}


second form
Code: Select all
<?php
class SsaSearchForm extends sfForm
{
   public function configure()
   {         
      $this->setWidgets(array(
      ''   => new sfWidgetFormJQueryAutocompleter(array('url' => 'Ssa/search'))  ));
   }   
}


third form
Code: Select all
<?php
class RootCauseSearchForm extends sfForm
{
   public function configure()
   {
      $this->setWidgets(array(
      ''   => new sfWidgetFormJQueryAutocompleter(array('url' => 'BaseDeConnaissance/root'))  ));
      
   }   
}


controller
Code: Select all
public function executeSymptome(sfWebRequest $request)
  {
     $this->getResponse()->setContentType('application/json');
     $symptome=SymptomePeer::searchSymptomeAjax($request->getParameter('q'),$request->getParameter('limit'));
      $this->renderText(json_encode($symptome));
     
      return sfView::NONE;
     
  }
 
  public function executeRoot(sfWebRequest $request)
  {
     $this->getResponse()->setContentType('application/json');
     $rootcause=RootcausePeer::searchRootcauseAjax($request->getParameter('q'),$request->getParameter('limit'));
     $this->renderText(json_encode($rootcause));
     
     return sfView::NONE;
  }
 
  public function executeImpact(sfWebRequest $request)
  {
     $this->getResponse()->setContentType('application/json');
     $impact=ImpactPeer::searchImpactAjax($request->getParameter('q'),$request->getParameter('limit'));
     $this->renderText(json_encode($impact));
     
     return sfView::NONE;
  }
 


index controller
Code: Select all
public function executeIndex(sfWebRequest $request)
     {
        $this->formRootCause= new RootCauseSearchForm();
        $this->RootCauseArray=RootcausePeer::getAllRootCause(
        $request->getParameter('pageRootCause'),
        sfConfig::get('app_total_items_rootcause'));
        
        $this->formSymptome= new SymptomeSearchForm();
        $this->symptomeArray=SymptomePeer::getAllSymptome(
        $request->getParameter('page'),
        sfConfig::get('app_total_items_symptome'));
      
        $this->formImpact= new ImpactSearchForm();
        $this->ImpactArray= ImpactPeer::getAllImpact(
        $request->getParameter('pageImpact'),
        sfConfig::get('app_total_items_impact'));
        
     return sfView::SUCCESS;
  }


just the first works
allel
Junior Member
 
Posts: 13
Joined: Tue Jun 15, 2010 11:38 am

Re: autocomplete doesn't work

by anamdeep » Fri Nov 26, 2010 9:37 pm

I am new here. I am in this problem.Thanks to your code information.I will apply your code for solve my problem.


cremation ash jewelry
anamdeep
Junior Member
 
Posts: 1
Joined: Fri Nov 26, 2010 9:21 pm