Selaa lähdekoodia

fixed a bug with the multivalue field and collapsed all but the last funding field item so that the form is less busy

Shawna Spoor 5 vuotta sitten
vanhempi
commit
a934601d30
1 muutettua tiedostoa jossa 33 lisäystä ja 12 poistoa
  1. 33 12
      tripal/includes/tripal.registration.inc

+ 33 - 12
tripal/includes/tripal.registration.inc

@@ -129,18 +129,40 @@ function tripal_registration_form($form, &$form_state) {
   );
   );
 
 
   $count = count($form_data['values']['funding']);
   $count = count($form_data['values']['funding']);
-  $form_state['details']['funding'] = $form_state['details']['funding'] + $count;
+  if ($form_state['details']['funding'] < $count) {
+    $form_state['details']['funding'] = $form_state['details']['funding'] + $count;
+  }
+  else {
+    $form_state['details']['funding'] = $form_state['details']['funding'] + 1;
+  }
+
   for ($i = 1; $i <= $form_state['details']['funding']; $i++) {
   for ($i = 1; $i <= $form_state['details']['funding']; $i++) {
-    $form['details']['funding'][$i] = array(
-      '#type' => 'fieldset',
-      '#title' => t("Funding Source $i"),
-      '#tree' => TRUE,
-      '#description' => t('When requesting funds for additional Tripal development, 
+    if ($i === $form_state['details']['funding']) {
+      $form['details']['funding'][$i] = array(
+        '#type' => 'fieldset',
+        '#title' => t("Funding Source $i"),
+        '#tree' => TRUE,
+        '#collapsible' => TRUE,
+        '#collapsed' => FALSE,
+        '#description' => t('When requesting funds for additional Tripal development, 
        it is important to report the breadth of of funding sources for Tripal sites.  
        it is important to report the breadth of of funding sources for Tripal sites.  
        Please consider sharing this information by providing the granting 
        Please consider sharing this information by providing the granting 
        agency, and funding periods.')
        agency, and funding periods.')
-    );
-
+      );
+    }
+    else {
+      $form['details']['funding'][$i] = array(
+        '#type' => 'fieldset',
+        '#title' => t("Funding Source $i"),
+        '#tree' => TRUE,
+        '#collapsible' => TRUE,
+        '#collapsed' => TRUE,
+        '#description' => t('When requesting funds for additional Tripal development, 
+       it is important to report the breadth of of funding sources for Tripal sites.  
+       Please consider sharing this information by providing the granting 
+       agency, and funding periods.')
+      );
+    }
     $form['details']['funding'][$i]['tripal_reg_site_agency'] = array(
     $form['details']['funding'][$i]['tripal_reg_site_agency'] = array(
       '#type' => 'textfield',
       '#type' => 'textfield',
       '#default_value' => isset($form_data['values']['funding'][$i]['tripal_reg_site_agency']) ? $form_data['values']['funding'][$i]['tripal_reg_site_agency'] : NULL,
       '#default_value' => isset($form_data['values']['funding'][$i]['tripal_reg_site_agency']) ? $form_data['values']['funding'][$i]['tripal_reg_site_agency'] : NULL,
@@ -154,7 +176,7 @@ function tripal_registration_form($form, &$form_state) {
     );
     );
     $form['details']['funding'][$i]['tripal_reg_site_amount'] = array(
     $form['details']['funding'][$i]['tripal_reg_site_amount'] = array(
       '#type' => 'textfield',
       '#type' => 'textfield',
-      '#default_value' => isset($form_data['values']['funding'][$i]['tripal_reg_site_amount']) ? $form_data['values']['funding'][$i]['tripal_reg_site_amount'] : null,
+      '#default_value' => isset($form_data['values']['funding'][$i]['tripal_reg_site_amount']) ? $form_data['values']['funding'][$i]['tripal_reg_site_amount'] : NULL,
       '#title' => t('Funding Amount'),
       '#title' => t('Funding Amount'),
     );
     );
 
 
@@ -180,8 +202,8 @@ function tripal_registration_form($form, &$form_state) {
       '#date_format' => 'Y',
       '#date_format' => 'Y',
     );
     );
   }
   }
-  
-  $form['details']['funding']['add_funding'] = array(
+
+  $form['details']['funding']['add_funding'] = array( 
     '#type' => 'button',
     '#type' => 'button',
     '#value' => t('Add additional funding sources'),
     '#value' => t('Add additional funding sources'),
     '#href' => '',
     '#href' => '',
@@ -190,7 +212,6 @@ function tripal_registration_form($form, &$form_state) {
       'wrapper' => 'funding',
       'wrapper' => 'funding',
     ),
     ),
   );
   );
-  $form_state['details']['funding']++;
 
 
   // Provide a submit button.
   // Provide a submit button.
   if (!empty($form_data)) {
   if (!empty($form_data)) {