Exemple #1
0
 /**
  * Generated and Returns HTML for URL questions
  * 
  * @param string SC Question ID
  * @param string Question title
  * @param string Question subtitle
  * @param bool Question required
  * @param string Answer
  * @return string HTML
  */
 private function get_question_url($id, $question)
 {
     # Assign attributes
     $input_attrs = [];
     $input_attrs[] = new Attr('type', 'url');
     $input_attrs[] = new Attr('id', $id);
     $input_attrs[] = new Attr('name', $id);
     $input_attrs[] = new Attr('autocomplete', 'on');
     $input_attrs[] = new Attr('maxlength', '255');
     $input_attrs[] = new Attr('size', '40');
     # Default/Current value
     $answers = $this->answers;
     if (isset($answers[$id])) {
         $input_attrs[] = new Attr('value', $answers[$id]);
     } elseif (!$this->ignoreDefaults && isset($question['default'])) {
         $input_attrs[] = new Attr('value', $question['default']);
     }
     # Required
     if (isset($question['required']) && $question['required']) {
         $input_attrs[] = new Attr('required');
     }
     # Generate HTML
     $html = '  <div class="' . $this->getFieldClasses($question, 'url') . '">' . "\n";
     $html .= $this->getQuestionHeader($question) . "\n";
     $html .= '      <input ' . Attr::displayAll($input_attrs) . '>' . "\n";
     $html .= '  </div>' . "\n";
     return $html;
 }