/[drupal]/contributions/modules/multiselect/multiselect.module
ViewVC logotype

Diff of /contributions/modules/multiselect/multiselect.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.7.2.1, Fri Feb 27 02:43:40 2009 UTC revision 1.7.2.2, Sun Mar 1 01:03:19 2009 UTC
# Line 121  function multiselect_select_process($ele Line 121  function multiselect_select_process($ele
121    $unselected_options = array();    $unselected_options = array();
122    $selected_options = array();    $selected_options = array();
123    
   // If we're only allowed to select a single item (multiple is disabled) generate a different widget  
   //if (!$field['multiple']) {  
 //      $newoptions = array();  
 //      foreach ($options as $key => $value) {  
 //        $newoptions[$key] = nodereference_allowed_values($field);  
 //      }  
 //      if (!$field['required']) {  
 //        $newoptions = array(0 => t('<none>')) + $newoptions;  
 //      }  
 //  
 //      $form[$element['#field_name']] = array('#tree' => TRUE);  
 //      $form[$element['#field_name']]['nids'] = array(  
 //        '#type' => 'select',  
 //        '#title' => t($field['widget']['label']),  
 //        '#default_value' => $items[0]['nids'],  
 //        '#multiple' => $field['multiple'],  
 //        '#size' =>  $field['multiple'] ? min(count($newoptions), 6) : 0,  
 //        '#options' => $newoptions,  
 //        '#required' => $field['required'],  
 //        '#description' => $field['widget']['description'],  
 //      );  
 //      return $form;  
 //    }// End of if single-item only  
   
124    // Insert Javascript and CSS for this widget.    // Insert Javascript and CSS for this widget.
125    $path = drupal_get_path('module', 'multiselect');    $path = drupal_get_path('module', 'multiselect');
126    drupal_add_js($path .'/multiselect.js');    drupal_add_js($path .'/multiselect.js');
# Line 203  function multiselect_select_process($ele Line 179  function multiselect_select_process($ele
179      '#suffix' => "\n</div>\n",      '#suffix' => "\n</div>\n",
180      '#attributes' => array('class' => "$selfield multiselect_sel", 'id' => $element['#field_name']),      '#attributes' => array('class' => "$selfield multiselect_sel", 'id' => $element['#field_name']),
181      '#default_value' => isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : NULL,      '#default_value' => isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : NULL,
     //'#after_build' => array('multiselect_fix_preview'),  
     //'#all_options' => $options, //list of all options (used by the #after_build function)  
     //'#prefix_pre' => $prefix_pre,  
     //'#prefix_post' => $prefix_post,  
182    );    );
183    
184    // Set #element_validate in a way that it will not wipe out other    // Set #element_validate in a way that it will not wipe out other
# Line 270  function _html_for_buttons($fieldname) { Line 242  function _html_for_buttons($fieldname) {
242  <li class=\"multiselect_add\" id=\"". $fieldname ."\"><a href=\"javascript:;\">Add</a></li>  <li class=\"multiselect_add\" id=\"". $fieldname ."\"><a href=\"javascript:;\">Add</a></li>
243  <li class=\"multiselect_remove\" id=\"". $fieldname ."\"><a href=\"javascript:;\">Remove</a></li>  <li class=\"multiselect_remove\" id=\"". $fieldname ."\"><a href=\"javascript:;\">Remove</a></li>
244  </ul>";  </ul>";
   $addremovebuttons = "<span class='multiselect_add' id=\"". $fieldname ."\">";  
   $addremovebuttons .= "<img align=\"top\" src=\"". $path ."/add.png\" alt=\"". t('add selection') ."\"></span>\n";  
   $addremovebuttons .= "<span class=\"multiselect_remove\" id=\"". $fieldname ."\">";  
   $addremovebuttons .= "<img align=\"bottom\" src=\"". $path ."/remove.png\" alt=\"". t('remove selection') ."\"></span>\n";  
245    return $buttons_code;    return $buttons_code;
246  }  }
   
 /**  
  * Alters the preview form to include the newly added items  
  */  
 /* function multiselect_fix_preview($form, $edit) {  
   //print_r("\n\nFORM:\n");  
   //print_r($form);  
   //print_r("\n\nEDIT:\n");  
   //print_r($edit);  
   //print_r("\n\nPOST:\n");  
   //print_r($_POST);  
   
   $source_array = $_POST;  
   foreach ($form['#parents'] as $key) {  
     $source_array = $source_array[$key];  
   }  
   $field = $form['#parents'][0];  
   $options = $form['#all_options'];  
   
   $selected_options = array();  
   
   if (is_array($source_array)) {  
     $form['#prefix'] = "";  
     $form['#prefix'] .= $form['#prefix_pre'];  
     foreach ($options as $key => $value) {  
       $inarray = FALSE;  
       foreach ($source_array as $x => $nid) {  
         if ($key == $nid) {  
           $inarray = TRUE;  
         }  
       }  
   
       if ($inarray) {  
            //selected  
         $selected_options[$key] = $value;  
       }  
       else {  
            //unselected  
         $form['#prefix'] .= "<option value='". $key ."'>". $value ."</options>";  
       }  
     }  
   
     $form['#prefix'] .= $form['#prefix_post'];  
   
     $form['#options'] = $options;  
   }  
   return $form;  
 }*/  

Legend:
Removed from v.1.7.2.1  
changed lines
  Added in v.1.7.2.2

  ViewVC Help
Powered by ViewVC 1.1.2