Autocompleting the search
To demonstrate how simple it is to use the JavaScript form widgets, we are going to add an autocomplete search form at the top of the menu page. After a user starts typing in the search box, results will be displayed on key up even before he/she clicks on the "search" button.
To complete this task, we will use a widget called sfWidgetFormPropelJQueryAutocompleter. This widget is very useful when we are dealing with a Propel object and need an autocomplete feature.
First, we need to create a new search form. Create the lib/form/MilkshakeSearchForm.class.php file and add the following code to it:
<?php
class MilkshakeSearchForm extends sfForm
{
public function configure()
{
$this->setWidgets(array
('url_slug' => new sfWidgetFormChoice(array
('choices' => array(),'renderer_class' => '
sfWidgetFormJQueryAutocompleter',
'renderer_options' =>
array('url' => '/menu/search',),
))
));
$this->widgetSchema->setFormFormatterName('div');
}
}
?...