some changes in the form structure
This commit is contained in:
		| @@ -693,21 +693,27 @@ function materio_search_api_advanced_search_form($form, &$form_state){ | |||||||
|  |  | ||||||
|   $form = array( |   $form = array( | ||||||
|     'title' => array( |     'title' => array( | ||||||
|       '#prefix' => "<h2>", |       '#prefix' => "<h3>", | ||||||
|       '#markup' => t("Advanced Search"), |       '#markup' => t("Advanced Search"), | ||||||
|       '#suffix' => "</h2>", |       '#suffix' => "</h3>", | ||||||
|     ) |     ) | ||||||
|   ); |   ); | ||||||
|  |  | ||||||
|   $vocabularies = variable_get('advancedsearchvocs', array()); |   $vocabularies = variable_get('advancedsearchvocs', array()); | ||||||
|  |  | ||||||
|  |   $form['slider'] = array( | ||||||
|  |     '#type' => 'fieldset', | ||||||
|  |     // '#title' => $voc->name, | ||||||
|  |     '#tree' => true, | ||||||
|  |   ); | ||||||
|  |  | ||||||
|   foreach ($vocabularies as $vid) { |   foreach ($vocabularies as $vid) { | ||||||
|     $voc = taxonomy_vocabulary_load($vid); |     $voc = taxonomy_vocabulary_load($vid); | ||||||
|     // dsm($voc, 'voc'); |     // dsm($voc, 'voc'); | ||||||
|  |  | ||||||
|     $form['voc-'.$vid] = array( |     $form['slider']['voc-'.$vid] = array( | ||||||
|       '#type' => 'fieldset', |       '#type' => 'fieldset', | ||||||
|       '#title' => $voc->name, |       // '#title' => $voc->name, | ||||||
|       '#tree' => true, |       '#tree' => true, | ||||||
|     ); |     ); | ||||||
|  |  | ||||||
| @@ -728,7 +734,7 @@ function materio_search_api_advanced_search_form($form, &$form_state){ | |||||||
|         || !count($children)) |         || !count($children)) | ||||||
|        continue; |        continue; | ||||||
|  |  | ||||||
|       $form['tree-'.$term->tid] = array( |       $form['slider']['voc-'.$vid]['tree-'.$term->tid] = array( | ||||||
|         '#type' => 'fieldset', |         '#type' => 'fieldset', | ||||||
|         // '#title' => $term->name, |         // '#title' => $term->name, | ||||||
|         '#attributes' => array("class"=>array("treelevel1")), |         '#attributes' => array("class"=>array("treelevel1")), | ||||||
| @@ -736,7 +742,7 @@ function materio_search_api_advanced_search_form($form, &$form_state){ | |||||||
|       ); |       ); | ||||||
|  |  | ||||||
|       $placeholder = t("Select an option"); |       $placeholder = t("Select an option"); | ||||||
|       $form['tree-'.$term->tid]['children'] = array( |       $form['slider']['voc-'.$vid]['tree-'.$term->tid]['children'] = array( | ||||||
|         '#type' => 'select', |         '#type' => 'select', | ||||||
|         '#title' =>  $term->name, |         '#title' =>  $term->name, | ||||||
|         '#attributes' => array( |         '#attributes' => array( | ||||||
| @@ -785,7 +791,7 @@ function materio_search_api_advanced_search_form($form, &$form_state){ | |||||||
|           if(count($dflt_values2)) |           if(count($dflt_values2)) | ||||||
|             $classes2[] = 'visible'; |             $classes2[] = 'visible'; | ||||||
|  |  | ||||||
|           $form['tree-'.$term->tid]['tid-'.$child->tid] = array( |           $form['slider']['voc-'.$vid]['tree-'.$term->tid]['tid-'.$child->tid] = array( | ||||||
|             '#type' => 'select', |             '#type' => 'select', | ||||||
|             '#title' => $child->name, |             '#title' => $child->name, | ||||||
|             '#multiple' => true, |             '#multiple' => true, | ||||||
| @@ -803,19 +809,19 @@ function materio_search_api_advanced_search_form($form, &$form_state){ | |||||||
|         } |         } | ||||||
|       } |       } | ||||||
|       if(count($options)){ |       if(count($options)){ | ||||||
|         $form['tree-'.$term->tid]['children']['#options'] = $options; |         $form['slider']['voc-'.$vid]['tree-'.$term->tid]['children']['#options'] = $options; | ||||||
|       }else{ |       }else{ | ||||||
|         unset($form['tree-'.$term->tid]); |         unset($form['slider']['voc-'.$vid]['tree-'.$term->tid]); | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   $form['show'] = array( |   $form['slider']['show'] = array( | ||||||
|     '#type' => 'submit',//'image_button', |     '#type' => 'image_button', | ||||||
|     // '#src' => drupal_get_path('module', 'materio_search_api') . '/images/search.png', |     '#src' => drupal_get_path('module', 'materio_search_api') . '/images/search.png', | ||||||
|     '#value' => t('Find'), |     '#value' => t('Find'), | ||||||
|     '#attributes' => array("class"=>array("btn","btn-lg")), |     // '#attributes' => array("class"=>array("btn","btn-lg")), | ||||||
|     '#prefix' => '<div class="submits">', |     '#prefix' => '<div class="submits">', | ||||||
|     '#suffix' => '</div>', |     '#suffix' => '</div>', | ||||||
|   ); |   ); | ||||||
| @@ -834,14 +840,17 @@ function materio_search_api_advanced_search_form_validate($form, &$form_state){ | |||||||
| function materio_search_api_advanced_search_form_submit($form, &$form_state){ | function materio_search_api_advanced_search_form_submit($form, &$form_state){ | ||||||
|   dsm($form, 'form'); |   dsm($form, 'form'); | ||||||
|   dsm($form_state, 'form_state'); |   dsm($form_state, 'form_state'); | ||||||
|   $fs_values = $form_state['values']; |   $fs_values = $form_state['values']['slider']; | ||||||
|  |   unset($fs_values['show']); | ||||||
|   dsm($fs_values, 'values'); |   dsm($fs_values, 'values'); | ||||||
|  |  | ||||||
|   foreach($fs_values as $tree => $values){ |   foreach($fs_values as $voc => $trees){ | ||||||
|     foreach ($values as $values => $selected) { |     foreach($trees as $tree => $values){ | ||||||
|       if(is_array($selected) && count($selected)){ |       foreach ($values as $values => $selected) { | ||||||
|         foreach ($selected as $tid) { |         if(is_array($selected) && count($selected)){ | ||||||
|           $tids[] = $tid; |           foreach ($selected as $tid) { | ||||||
|  |             $tids[] = $tid; | ||||||
|  |           } | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Bachir Soussi Chiadmi
					Bachir Soussi Chiadmi