/**
  * @param IRSVPTemplate $template
  * @param IRSVP $rsvp
  * @param ISummitEvent $event
  * @param string $form_name
  * @return BootstrapForm|PresentationSpeaker
  */
 public function build(IRSVPTemplate $template, IRSVP $rsvp, ISummitEvent $event, $form_name = 'RSVPForm')
 {
     $fields = new FieldList();
     foreach ($template->getQuestions() as $q) {
         $type = $q->Type();
         $builder_class = $type . 'UIBuilder';
         // @IRSVPQuestionTemplateUIBuilder
         $builder = Injector::inst()->create($builder_class);
         $answer = $rsvp ? $rsvp->findAnswerByQuestion($q) : null;
         $field = $builder->build($rsvp, $q, $answer);
         $fields->add($field);
     }
     $validator = null;
     if ($rsvp) {
         $fields->add(new HiddenField('rsvp_id', 'rsvp_id', $rsvp->getIdentifier()));
     }
     $fields->add(new HiddenField('event_id', 'event_id', $event->getIdentifier()));
     $fields->add(new HiddenField('summit_id', 'summit_id', $event->Summit()->getIdentifier()));
     $fields->add(new HiddenField('seat_type', 'seat_type', $event->getCurrentRSVPSubmissionSeatType()));
     $fields->add(new LiteralField('hr', '<hr>'));
     $actions = new FieldList(FormAction::create('submit_rsvp')->setTitle('Send RSVP')->addExtraClass('rsvp_submit'));
     $form = new BootstrapForm(Controller::curr(), $form_name . '_' . $event->getIdentifier(), $fields, $actions, $validator);
     $form->setAttribute('class', 'rsvp_form');
     return $form;
 }
 /**
  * @param IRSVP $rsvp
  * @param IRSVPQuestionTemplate $question
  * @param IRSVPAnswer $answer
  * @return FormField
  */
 public function build(IRSVP $rsvp, IRSVPQuestionTemplate $question, IRSVPAnswer $answer)
 {
     $field = new TextField($question->name(), $question->label());
     if ($rsvp) {
         $field->setValue($rsvp->findAnswerByQuestion($question)->Value);
     } else {
         $field->setValue($question->initialValue());
     }
     if ($question->isReadOnly()) {
         $field->setDisabled(true);
     }
     if ($question->isMandatory()) {
         $field->setAttribute('data-rule-required', 'true');
     }
     if (!is_null($answer)) {
         $field->setValue($answer->value());
     }
     return $this->buildDependantRules($rsvp, $question, $field);
 }