/** * Variant Form Dropdown * * Returns a HTML dropdown element with a proper id, name, label, * options, and default selection. Also locks/unlocks the field for editing * and highlights the field if it has been changed in any way. By * default, the field is unlocked for editing. * * @author Sean Ephraim * @access public * @param string $field * Field name (database name) * @param string $label * Field label (human-readable name) * @param array $options * Selectable options * @param mixed $default_selection * Default selection * @param boolean $editable * (optional) Editable field or not (default = TRUE) * @return string HTML dropdown element */ function variant_form_dropdown($field, $label, $options, $default_selection, $editable = TRUE) { // Get the variation's unique ID from the URI $variation_id = get_instance()->uri->segment(3); // Did the user already try to submit this field (and an error was thrown)? // ... if so, get that value back from POST if (isset($_POST[$field])) { $default_selection = $_POST[$field]; } $html = ''; if ($editable === TRUE) { $highlight = highlight_if_changed($variation_id, $field); // Editable input $html .= '<label for="' . $field . '">'; $html .= $label . ' <span class="edit-icon-wrapper"><i class="icon-pencil"></i></span>'; $html .= '</label>'; $html .= '<select id="' . $field . '" name="' . $field . '" class="' . $highlight . '">'; foreach ($options as $option) { $html .= ' <option value="' . $option . '" ' . select_option_if_matching($option, $default_selection) . '>' . $option . '</option>'; } $html .= '</select>'; } else { $highlight = ''; // Don't highlight uneditable input // Uneditable input -- not actually input at all :0 $html .= "<div>{$label}</div>"; $html .= '<span id="' . $field . '" class="input-xlarge uneditable-input ' . $highlight . '">' . $default_selection . '</span>'; } return $html; }
?> <?php echo variant_form_input('gerp_pred', 'GERP++ Prediction', $variation->gerp_pred, $unlock); ?> </div> </div> </div> </div> <?php echo edit_allele_frequencies($variation, $unlock); ?> <label for="comments"> Comments <span class="edit-icon-wrapper"><i class="icon-pencil"></i></span> </label> <textarea id="comments" name="comments" class="input-block-level <?php echo highlight_if_changed($variation->id, 'comments'); ?> " rows="3"><?php echo set_value('comments', $variation->comments); ?> </textarea> <div> <div class="accordion" id="accordion-informatics-team"> <div class="accordion-group"> <div class="accordion-heading"> <a class="accordion-toggle rowlink" data-toggle="collapse" data-parent="#accordion-informatics-team" href="#informatics-team"> <i class="icon-plus"></i> For The Informatics Team </a> </div> <div id="informatics-team" class="accordion-body collapse"> <div class="accordion-inner">