sfWidgetFormDoctrineJQueryAutocompleter dans sfGuardUserAdminForm
bon, la question du jour :mrgreen:
voila dans mon formulaire sfGuardUserAdminForm j'ai un champ section lié a une table section.
Le plugin m' a créé un champ select...
sauf que vu le nombre de section que j'ai, c'est pas ergonomique, j'ai donc voulu le remplacer par un sfWidgetFormDoctrineJQueryAutocompleter (mode d'emploi applique ici
ça donne:
sfGuardUserAdminForm:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
class sfGuardUserAdminForm extends BasesfGuardUserAdminForm
{
/**
* @see sfForm
*/
public function configure()
{
sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url'));
$this->widgetSchema['section_id']->setOption('renderer_class', 'sfWidgetFormDoctrineJQueryAutocompleter');
$this->widgetSchema['section_id'] = new sfWidgetFormDoctrineJQueryAutocompleter(
array(
'model' => "Section",
'url' => url_for("@ajax_section")
), array('size' => 100)
);
}
} |
routing de mon apps:
Code:
1 2 3 4
|
ajax_section:
url: /ajax-section
param: { module: Section, action: ajaxSection } |
mon action:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
class Section extends BaseSection
{
public function executeAjaxSection(sfWebRequest $request)
{
$this->getResponse()->setContentType('application/json');
$choices = array();
foreach($section = Doctrine::getTable('Section')->getSectionAutocompletion($request->getParameter('q'), $request->getParameter('limit'))->getData() as $p)
{
$choices[$p->id] = $p->titre;
}
if($section != array())
{
return $this->renderText(json_encode($choices));
}
}
} |
et mon model table:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
class SectionTable extends Doctrine_Table
{
public static function getInstance()
{
return Doctrine_Core::getTable('Section');
}
public function getSectionAutocompletion($q, $limit)
{
$dq = Doctrine_Query::create()
->select("p.id, p.name")
->from("Section p")
->where("p.name LIKE ?","%".$q."%")
->limit($limit)
->orderBy('p.name ASC');
return $dq->execute();
}
} |
sauf que quand je tape le début d'une section, rien ne se produit, en allant dans firebug, il me donne ça comme insulte
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict
.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>sfError404Exception: Action "Section/ajaxSection" does not exist.</title>
<style type="text/css"> |
vous auriez des pistes ?