开发者

how can I get a label back on my autocomplete field in cakephp

开发者 https://www.devze.com 2023-03-08 03:06 出处:网络
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

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' wr开发者_JAVA技巧itten 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


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消