You might want to have a look to this : http://rabaix.net/en/articles/2009/02/23/let-s-be-more-dynamic-with-sf-form
I need to blog more about this .... On Mon, Jul 13, 2009 at 2:55 PM, cleve <cleve...@gmail.com> wrote: > > 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')", > )) ?> > > » > <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 > > > -- Thomas Rabaix http://rabaix.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---