Code snippets for symfony 1.x


Refine Tags

Snippets tagged "admindoublelist"

doctrine_admin_double_list in Symfony 1.2

When working with the admin generator in Symfony 1.2, I found I could no longer use the doctrine_admin_double_list field type. After hours of searching, I finally figured out how to get this functionality back. It can no longer be done from the generator.yml file, instead you need to modify your table's form class, e.g. lib/form/doctrine/XXXForm.class.php:

class XXXForm extends BaseXXXForm
  public function configure()
    $this->widgetSchema['field_name'] = new sfWidgetFormDoctrineChoice(array(
      'model'           => 'ModelName',
      'add_empty'       =>  false,
      'renderer_class'  => 'sfWidgetFormSelectDoubleList',

This requires the sfFormExtraPlugin plugin to be installed.

I assume this will work equally well with Propel. See symfony Forms in Action for more info.

by Ryan Hayle on 2009-04-02, tagged admindoublelist  doctrine  doctrineadmindoublelist  manytomany 

Quick Search for admin_double_list

Sometimes in the generator you have a large listing of elements in a admin_double_list.

Well I wanted to write a quick little autocomplete text box that would search for results and when you selected one, it would be added into the associated select box.

In your generator add a new partial: edit: display: [ _quick_search ]

Create a file in your templates directory called _quick_search.php

Copy this code in there:


<?php $response = sfContext::getInstance()->getResponse(); $response->addJavascript(sfConfig::get('sf_prototype_web_dir').'/js/prototype'); $response->addJavascript(sfConfig::get('sf_prototype_web_dir').'/js/effects'); $response->addJavascript(sfConfig::get('sf_prototype_web_dir').'/js/controls'); $response->addStylesheet(sfConfig::get('sf_prototype_web_dir').'/css/input_auto_complete_tag'); ?> <input type="text" id="quick_search" name="quick_search"/>

<div class="auto_complete" id="quick_search_auto_complete" style="position: absolute; left: 445px; top: 421px; width: 113px; opacity: 0.17329; display: none;">


<script type="text/javascript">


function addSelection (li)


$('associated_titles').options[ $('associated_titles').options.length] = new Option (li.childNodes[0].nodeValue,;


new Ajax.Autocompleter('quick_search', 'quick_search_auto_complete', '/backend_dev.php/search', { updateElement: addSelection });




Make sure you change your url from /backend_dev.php/search to whatever your action that will search your database and your good to go!

Just FYI: You can use the Symfony helper autocomplete_tag () because it does not allow for passing the updateElement parameter.

by Myke Hines on 2007-06-29, tagged admin  admindoublelist  admingenerator  ajax  generator