ZF-10931: Duplicate Dojo Data Store when using identical jsId

Description

In some cases you may want FilteringSelects or ComboBoxes to share the same store. The following code creates two FilteringSelects using the same store by setting the same id.


<?= new Zend_Dojo_Form_Element_FilteringSelect(
    'id1',
    array(
        'label' => 'ID1',
        'storeId'   => 'fooStore',
        'storeType' => 'dojo.data.ItemFileReadStore',
        'storeParams' => array(
            'url' => '/dojo/grid/data'
        ),
        'dijitParams' => array(
            'pageSize' => 5,
            'autocomplete' => 'false',
            'queryExpr' => '*${0}*'
        )
    )
); ?>

<?= new Zend_Dojo_Form_Element_FilteringSelect(
    'id2',
    array(
        'label' => 'ID2',
        'storeId'   => 'fooStore',
        'storeType' => 'dojo.data.ItemFileReadStore',
        'storeParams' => array(
            'url' => '/dojo/grid/data'
        ),
        'dijitParams' => array(
            'pageSize' => 5,
            'autocomplete' => 'false',
            'queryExpr' => '*${0}*'
        )
    )
); ?>

The generated code creates two separate stores with the same id.


ID1

ID2

This doesn't seem to be critical for dojo (yet). Maybe there is a way for the dojo view helper to check if the jsId for the store has already been set and eventually throw out an error.

If a second element uses an existing id the element should automatically get the same parameters for the store. In this case you only have to set the storeId an leave out the storeParams which are required at the moment.

Comments

No comments to display