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