Zend Framework

Hello! I'm currently working on PHP and i'm relatively new to the Zend Framework. I was wondering if you could help me a teeny bit with an issue i have right now. I have tried to build an autocomplete input field, and have successfully done so with the help of your article at the following url: http://techchorus.net/autocomplete-example-zenddojoformelementfiltringse.... However, the issue i've run into now is, i want to populate a form with necessary information based on the value selected or entered in the autocomplete field. Say for instance, if the 'username' is selected from the autocomplete field, then there should be some fields in the form for 'First Name', 'Last Name' and say 'Address' which should automatically be filled up and which correspond to the 'username' selected. And of course, all field information should be pulled out of a database table. I would be really grateful if you could help me out with this. If you could give me an explanation of how i can do it, then that would be great. If you could code a simple example for me, that would be awesome too!
Thanks in advance!


subscribe to onChange

This question is actually related to JavaScript.

If your data store already contains the first name, last name and address records, you can achieve what you want in two steps:

  1. Subscribe to onChange event of your filteringSelect widget. Your function will be called when the user selects an item.
  2. In your function grab the store and use fetchItemByIdentity method of the store and update the other fields.

I'd highly recommend you to get familiar with Dojo Toolkit's :

Sudheer
Binary Vibes

Thanks Sudheer! I have made a

Thanks Sudheer! I have made a change to my approach to create the auto-complete field. I've used ZendX_JQuery now, and it just takes a sinlge line of code to set up the auto-complete field, and it does seem a little convenient. However, all the examples that i've looked up have the values being displayed by the auto-complete field declared statically (values are hard coded). Any suggestions on how i might be able to make the field display values that i can pull out of a database would be great. And ideas on populating the form again based on value selected would be great as well. Thanks so much once again for taking the time to do this.

I don't know what made you

I don't know what made you switch to jQuery.

dijit.form.FilteringSelect suits your needs. You just have to write a function and have it called on the FilteringSelect widget's onChance. In your function you could either fetch the values for first name and address from the already existing store or fetch from server by making an AJAX call.

Sudheer
Binary Vibes

Hi! I have a relatively

This comment has been moved here.

Can you tell me how i can

Can you tell me how i can fire a controller/action when i select or enter a value in the autocomplete input field? I have tried using the 'onclick' event for the autocomplete field, but i'm not sure how to enter html attributes for it. Can you write me the syntax for it?

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>. The supported tag styles are: <foo>, [foo].

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.