1 ajax_example_autocomplete.inc | ajax_example_simple_autocomplete($form, &$form_state) |
A simple autocomplete form which just looks up usernames in the user table.
Parameters
array $form: Form API form.
array $form_state: Form API form.
Return value
array: Form array.
File
- modules/
examples/ ajax_example/ ajax_example_autocomplete.inc, line 29 - ajax_example_autocomplete.inc
Code
function ajax_example_simple_autocomplete($form, &$form_state) {
$form['info'] = array(
'#markup' => '<div>' . t("This example does a simplest possible autocomplete by username. You'll need a few users on your system for it to make sense.") . '</div>',
);
$form['user'] = array(
'#type' => 'textfield',
'#title' => t('Choose a user (or a people, depending on your usage preference)'),
// The autocomplete path is provided in hook_menu in ajax_example.module.
'#autocomplete_path' => 'examples/ajax_example/simple_user_autocomplete_callback',
);
return $form;
}