Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 1.04 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. class LastSurveyForm extends BaseForm
  2. {
  3.  
  4.    public function configure()
  5.     {  
  6.        
  7.         $survey = Doctrine::getTable( 'Survey' )->getLast();
  8.         $q = Doctrine::getTable( 'SurveyAnswer' )
  9.                 ->createQuery( 'a' )
  10.                 ->where( 'survey_id = ?', $survey->getid() );
  11.        
  12.         $widget = new sfWidgetFormInputHidden();
  13.         $this->setWidget( 'survey_id', $widget->setDefault( $survey->getid() ) );
  14.                
  15.         $this->widgetSchema['answer'] = new sfWidgetFormDoctrineChoice(array(
  16.                 'model'    => 'SurveyAnswer',
  17.                         //'order_by' => array('id', 'asc'),
  18.                 'multiple' => false,
  19.                         'expanded' => true,
  20.                         //'method'   => '__toString',
  21.                         'method'   => 'getAnswer',
  22.                 'query'    => $q,
  23.         ));
  24.        
  25.         /*
  26.         $this->setValidators(array(
  27.                 'answer' => new sfValidatorChoice( array(
  28.                         'choices' => array_keys( Doctrine::getTable( 'Survey' )->getLast()->getAnswers() )
  29.                 ))
  30.         ));
  31.         */
  32.  
  33.         $this->widgetSchema->setNameFormat('survey[%s]');
  34.         $this->normalizeValidatorSchema();
  35.     }
  36. }