How to save the ID not the text of a Zend_Dojo_Form_Element_ComboBox

Hi all,

I've found how to create a Zend_Dojo_Form_Element_ComboBox to read from a data store and display the results in a autocomplete manner.

I was just wondering if anyone could tell me how to access the associated id of the data displayed in the ComboBox so that I can save the id to the database, as currently the text e.g. Dublin is being saved, not its ID of 10.

Currently my ComboBox code is as follows.
 // Create a autocomplete input for counties
	    $county = new Zend_Dojo_Form_Element_ComboBox('county');
          'autocomplete' => true,
          'storeId'   => 'countyStore',
          'storeType' => '',
          'storeParams' => array('url' => "/clients/client/autocomplete"),
          'dijitParams' => array('searchAttr' => 'county')))
            ->addValidator('NotEmpty', true)

Open in new window

The code for my autocomplete action within the controller is as follows the query returns the ID and County for each county in the table, with the id of the table 'countiesID' being used as the id of the Zend_Dojo_Data element (if I understand what I've read from the web).

public function autocompleteAction()
  	// disable layout and view rendering
	// get list of breed names from the breeds table
	 $qry= Doctrine_Query::create()
	  	->from('PetManager_Model_Counties c');
	   //generate and return JSON string 
	   $data = new Zend_Dojo_Data('countiesID',$result,'county');
	   echo $data->toJson();

Open in new window

Many thanks in advance

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

IrishStudentAuthor Commented:
I've actually figured this out mysrelf I should have used FilteringSelect instead of combobox.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IrishStudentAuthor Commented:
I found the solution myself and no one on here had provided the answer.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.