0
votes

Hey there, I have a search box on my cakephp 1.3 site which I've just converted into being an autocomplete field using the ajax helper. All works fine but I used to be able to label the field, ie by using this:

echo $form->create("Charity",array('action' => 'search'));
echo $form->input("Charity.charity_name", array('label' => 'Search for'));
echo $form->end("Search");

I would have my search box with 'Search for' written above it.

Now using the autocomplete helper I use:

echo $form->create("Charity",array('action' => 'search'));
echo $ajax->autoComplete('Charity.charity_name', '/charities/autoComplete', array('label' => 'Search for'));
echo $form->end("Search");

Unfortunately my adding array('label' => 'Search for') doesn't have the desired effect. I know there are options available for autocomplete but apparently label isn't one of them. How can I get my label back :)

thanks in advance

2

2 Answers

1
votes

There is not a "cake" way to add the label for autocomplete boxes. Your best bet is to write the code around it yourself, like etc just like you see around cake generated inputs. Might be worth putting in a ticket to the CakePHP guys to see if they can fix that in the next round.

0
votes

A quick look into the API: http://api13.cakephp.org/class/ajax-helper#method-AjaxHelperautoComplete, the $options array is for Ajax options.

The method uses FormHelpers text method, so it just creates the input, without the whole wrapping.