/**
  * @param IRSVP $rsvp
  * @param IRSVPQuestionTemplate $question
  * @param IRSVPAnswer $answer
  * @return FormField
  */
 public function build(IRSVP $rsvp, IRSVPQuestionTemplate $question, IRSVPAnswer $answer)
 {
     $options = array();
     foreach ($question->Values()->sort('Order') as $val) {
         $options[$val->ID] = empty($val->Label) ? $val->Value : $val->Label;
     }
     $field = new OptionsetField($question->name(), $question->label(), $options);
     $default_value = $question->getDefaultValue();
     if (!is_null($default_value) && $default_value->ID > 0) {
         $field->setValue($default_value->ID);
     }
     if ($question->isReadOnly()) {
         $field->setDisabled(true);
     }
     if ($question->isMandatory()) {
         $field->setAttribute('data-rule-required', 'true');
     }
     if (!is_null($answer)) {
         $field->setValue($answer->value());
     }
     $field->setTemplate('RSVPOptionSetField');
     return $this->buildDependantRules($rsvp, $question, $field);
 }