Tripal v1.0 (6.x-1.0)
|
Go to the source code of this file.
Functions | |
tripal_views_elements () | |
expand_file_upload_combo ($element, $edit, $form_state, $complete_form) | |
expand_sequence_combo ($element, $edit, $form_state, $complete_form) | |
theme_file_upload_combo ($element) | |
theme_sequence_combo ($element) | |
file_upload_combo_validate ($element, &$form) | |
sequence_combo_validate ($element, &$form) |
Form elements used for tripal views
Definition in file tripal_views_form_elements.inc.
expand_file_upload_combo | ( | $ | element, |
$ | edit, | ||
$ | form_state, | ||
$ | complete_form | ||
) |
Upload File and keep track of previously uploaded files Form element description
Definition at line 32 of file tripal_views_form_elements.inc.
{ // set the default values for each field if (empty($element['#value'])) { $element['#value'] = array( 'items' => '', 'items_file' => '', 'file_path' => '', ); } $element['#tree'] = TRUE; // add items text area element $parents = $element['#parents']; $parents[] = 'items'; $element['items'] = array( '#type' => 'textarea', '#default_value' => $element['#value']['items'], ); // add file upload element $parents = $element['#parents']; $parents[] = 'items_file'; $element['items_file'] = array( '#type' => 'file', '#title' => 'File upload', '#default_value' => $element['#value']['items_file'], ); // add hidden elelment $parents = $element['#parents']; $parents[] = 'file_path'; $element['file_path'] = array( '#type' => 'hidden', '#default_value' => $element['#value']['file_path'], ); return $element; }
expand_sequence_combo | ( | $ | element, |
$ | edit, | ||
$ | form_state, | ||
$ | complete_form | ||
) |
Form element description
Definition at line 75 of file tripal_views_form_elements.inc.
{ // set the default values for each field if (empty($element['#value'])) { $element['#value'] = array( 'upstream' => '', 'downstream' => '', ); } $element['#tree'] = TRUE; // add the upstream box $parents = $element['#parents']; $parents[] = 'upstream'; $element['upstream'] = array( '#type' => 'textfield', '#title' => t('Get Upstream Bases'), '#description' => t('Specify the number of upstream bases to include in the sequnce'), '#default_value' => $element['#value']['upstream'], ); // add the downstream box $parents = $element['#parents']; $parents[] = 'downstream'; $element['downstream'] = array( '#type' => 'textfield', '#prefix' => '<br>', '#title' => t('Get Downstream Bases'), '#description' => t('Specify the number of downstream bases to include in the sequnce'), '#default_value' => $element['#value']['downstream'], ); return $element; }
file_upload_combo_validate | ( | $ | element, |
&$ | form | ||
) |
Validate all content passed into the file upload combo form element
Definition at line 126 of file tripal_views_form_elements.inc.
{ $file = file_save_upload($element['#name'], array()); if ($file) { $form['values'][$element['#name']]['file_path'] = $file->filepath; // we need to add our file path to the $_GET element as if it were // submitted along with the rest of the form $_GET[$element['#name']]['file_path'] = $file->filepath; } }
sequence_combo_validate | ( | $ | element, |
&$ | form | ||
) |
Validate all content passed into the sequence combo form element
Definition at line 139 of file tripal_views_form_elements.inc.
{ $upstream = $form['values'][$element['#name']]['upstream']; $downstream = $form['values'][$element['#name']]['downstream']; if ($upstream < 0) { form_set_error($element['#name'], 'Please provide a positive number for upstream bases'); } if ($upstream and !preg_match('/^\d+$/', $upstream)) { form_set_error($element['#name'], 'Please provide a decimal number for upstream bases'); } if ($downstream < 0) { form_set_error($element['#name'], 'Please provide a positive number for downstream bases'); } if ($downstream and !preg_match('/^\d+$/', $downstream)) { form_set_error($element['#name'], 'Please provide a decimal number for downstream bases'); } }
theme_file_upload_combo | ( | $ | element | ) |
Theme the file upload combo form element
Definition at line 112 of file tripal_views_form_elements.inc.
{ return theme('form_element', $element, '<div class="container-inline">' . $element['#children'] . '</div>'); }
theme_sequence_combo | ( | $ | element | ) |
Theme the file sequence form element
Definition at line 119 of file tripal_views_form_elements.inc.
{ return theme('form_element', $element, '<div class="container-inline">' . $element['#children'] . '</div>'); }
tripal_views_elements | ( | ) |
Register form elements
Definition at line 11 of file tripal_views_form_elements.inc.
{ $type['file_upload_combo'] = array( '#input' => TRUE, '#process' => array('expand_file_upload_combo'), '#element_validate' => array('file_upload_combo_validate'), ); $type['sequence_combo'] = array( '#input' => TRUE, '#process' => array('expand_sequence_combo'), '#element_validate' => array('sequence_combo_validate'), ); return $type; }