
Untitled
By: a guest on
May 8th, 2012 | syntax:
None | size: 1.04 KB | hits: 15 | expires: Never
class LastSurveyForm extends BaseForm
{
public function configure()
{
$survey = Doctrine::getTable( 'Survey' )->getLast();
$q = Doctrine::getTable( 'SurveyAnswer' )
->createQuery( 'a' )
->where( 'survey_id = ?', $survey->getid() );
$widget = new sfWidgetFormInputHidden();
$this->setWidget( 'survey_id', $widget->setDefault( $survey->getid() ) );
$this->widgetSchema['answer'] = new sfWidgetFormDoctrineChoice(array(
'model' => 'SurveyAnswer',
//'order_by' => array('id', 'asc'),
'multiple' => false,
'expanded' => true,
//'method' => '__toString',
'method' => 'getAnswer',
'query' => $q,
));
/*
$this->setValidators(array(
'answer' => new sfValidatorChoice( array(
'choices' => array_keys( Doctrine::getTable( 'Survey' )->getLast()->getAnswers() )
))
));
*/
$this->widgetSchema->setNameFormat('survey[%s]');
$this->normalizeValidatorSchema();
}
}