views:

703

answers:

3

Hi,

I'm trying to get a filtering select work with a Dojo enabled form using the Zend Framework. The form allows the user to update their details such as address, urls etc for their profile. However elements in the form are using a filiteringselect for things such as country and state/county.

I want to get this to default with the value that I pass in to the form when populating it, however this does not work.

I'm populating the form like

$form->getElement('country')->setValue($country);

$country will be values such as United Kingdom, France, Spain etc...

These values are stored in the database in a table of [id], [name]. Which is accessed by the element in the Zend Form

$county  = new Zend_Dojo_Form_Element_FilteringSelect('county');
    $county->setRequired(true)
        ->setStoreId('countystore')
        ->setStoreType('dojo.data.ItemFileReadStore')
        ->setStoreParams(array('url' => $baseUrl.'/dojo/counties'))
        ->setAttrib('searchAttr', 'name')
        ->removeDecorator('DtDdWrapper')
        ->removeDecorator('label')
        ->removeDecorator('HtmlTag');

However the setValue to populate/default the element doesn't work. Is there a specific way of doing this with Zend_Forms and Dojo?

Thanks in advance...

A: 

In straight up dojo you could do this:

  dijit.byId('myFiltertingSelect').attr('value',newValue);

You should be able to just add:

  ->setAttrib('value',$newValue)
seth
A: 

same problem here, iam trying now for hours to get this working. How to try your "straight" dojo way ?

Roland Canton
A: 

Using Zend_Dojo_Form_Element_FilteringSelect, this will work (ZF 1.10.7):

$form->getElement('country')->setAttrib('displayedValue', $country);

Straight Dojo Way:

dijit.byId('country').attr('displayedValue', newValue);

http://dojotoolkit.org/api/dijit/form/FilteringSelect.html#displayedValue

dharnan