SHARE
TWEET

Untitled

a guest Jul 19th, 2017 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Index: lib/filter/doctrine/BaseFormFilterDoctrine.class.php
  2. ===================================================================
  3. --- lib/filter/doctrine/BaseFormFilterDoctrine.class.php    (revision 20489)
  4. +++ lib/filter/doctrine/BaseFormFilterDoctrine.class.php    (working copy)
  5. @@ -10,8 +10,48 @@
  6.  {
  7.    public function setup()
  8.    {
  9. +    $this->addAutocompleters();
  10. +
  11. +    parent::setup();
  12.    }
  13.  
  14. +  protected function addAutocompleters()
  15. +  {
  16. +    $classes = array(
  17. +      'sfGuardUser' => 'user'
  18. +    );
  19. +
  20. +    foreach($this->getFormFieldSchema() as $name => $field)
  21. +    {
  22. +      $widget = $field->getWidget();
  23. +      if ($widget instanceof sfWidgetFormDoctrineChoice)
  24. +      {
  25. +        $options = $widget->getOptions();
  26. +
  27. +        // we don't want to replace widget for this model
  28. +        if (!isset($classes[$options['model']]))
  29. +        {
  30. +          continue;
  31. +        }
  32. +
  33. +        // customized query, do not replace the widget
  34. +        if ($options['key_method'] != 'getPrimaryKey' || $options['query'] != null)
  35. +        {
  36. +          continue;
  37. +        }
  38. +
  39. +        // replace the widget by a sfWidgetFormJQueryAutocompleter
  40. +        $this->widgetSchema[$name] = mrForm::getAutoCompleteWidget(
  41. +          $classes[$options['model']],
  42. +          'sfWidgetFormJQueryAutocompleter',
  43. +          array(
  44. +            'value_callback' => array(Doctrine::getTable($options['model']), 'getVisibleValue')
  45. +          )
  46. +        );
  47. +      }
  48. +    }
  49. +  }
  50. +
  51.    /**
  52.     * @see BaseFormDoctrine. (this is copy base paste to override the limitation
  53.     * of the shitty inheritance of doctrine forms in 1.2)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top