Ok this is how I did it, but everything is outside a form / table
class:

Partial to override default admin generator field venue_id
_venue_id.php
------------------------

<?php use_helper('Javascript')?>

<div class="sf_admin_form_row sf_admin_foreignkey">
  <?php echo $form['venue_id']->renderError() ?>
  <div>
    <?php echo $form['venue_id']->renderLabel('Venue') ?>

    <?php
    $w = new sfWidgetFormDoctrineChoice(array('model' => 'District',
'add_empty' => '--Filter by District--'));
    echo $w->render('district_id', null, array('id' =>
'district'));
    ?>

    <?php echo observe_field('district', array(
        'update'   => 'district-select',
        'url'      => '/admin.php/course/selectVenue',
        'with'     => "'district=' + value",
        'loading'  => "Element.show('indicator');Element.hide('gp-
select')",
        'complete' => "Element.hide('indicator');Element.show('gp-
select')",
    )) ?>

     &raquo;
    <span id="district-select"><?php echo $form['venue_id']->render
($attributes) ?></span>

    <div id="indicator" style="display: none"></div>

  </div>
</div>


AJAX action to return filtered select
---------------------------------------------------

  public function executeSelectVenue($request){

    $this->forward404Unless($request->isXmlHttpRequest());
    $this->forward404Unless($request->hasParameter('district'));

    $q = Doctrine_Query::create()
    ->from('Venue v')
    ->where('v.district_id  = ?', $request->getParameter('district'));

    $w = new sfWidgetFormDoctrineChoice(array('model' => 'Venue',
'query' => $q));
    return $this->renderText($w->render('course[venue_id]'));

  }


It feels odd to create widgets in the partial / action but overkill to
create an additional class? What does everyone think?

I'll make a snipeet of this when its tidy! (and Refactored
properly :-)

John
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to