Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: lib/filter/doctrine/BaseFormFilterDoctrine.class.php
- ===================================================================
- --- lib/filter/doctrine/BaseFormFilterDoctrine.class.php (revision 20489)
- +++ lib/filter/doctrine/BaseFormFilterDoctrine.class.php (working copy)
- @@ -10,8 +10,48 @@
- {
- public function setup()
- {
- + $this->addAutocompleters();
- +
- + parent::setup();
- }
- + protected function addAutocompleters()
- + {
- + $classes = array(
- + 'sfGuardUser' => 'user'
- + );
- +
- + foreach($this->getFormFieldSchema() as $name => $field)
- + {
- + $widget = $field->getWidget();
- + if ($widget instanceof sfWidgetFormDoctrineChoice)
- + {
- + $options = $widget->getOptions();
- +
- + // we don't want to replace widget for this model
- + if (!isset($classes[$options['model']]))
- + {
- + continue;
- + }
- +
- + // customized query, do not replace the widget
- + if ($options['key_method'] != 'getPrimaryKey' || $options['query'] != null)
- + {
- + continue;
- + }
- +
- + // replace the widget by a sfWidgetFormJQueryAutocompleter
- + $this->widgetSchema[$name] = mrForm::getAutoCompleteWidget(
- + $classes[$options['model']],
- + 'sfWidgetFormJQueryAutocompleter',
- + array(
- + 'value_callback' => array(Doctrine::getTable($options['model']), 'getVisibleValue')
- + )
- + );
- + }
- + }
- + }
- +
- /**
- * @see BaseFormDoctrine. (this is copy base paste to override the limitation
- * of the shitty inheritance of doctrine forms in 1.2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement