Facet removal
authorJason Skomorowski <jason@indexdata.com>
Wed, 30 Mar 2011 04:23:53 +0000 (04:23 +0000)
committerJason Skomorowski <jason@indexdata.com>
Wed, 30 Mar 2011 04:23:53 +0000 (04:23 +0000)
mkdru.module

index d988da7..caf1341 100644 (file)
@@ -236,6 +236,16 @@ function mkdru_settings_form(&$form_state) {
       '#size' => 3,
       '#maxlength' => 3,
     );
+    $form['settings']['facets'][$facet]['remove'] = array(
+      '#type' => 'submit',
+      '#value' => t('Remove facet'),
+      '#mkdru facet' => $facet,
+      '#submit' => array('mkdru_remove_facet_submit'),
+      '#ahah' => array(
+        'path' => 'ahah-mkdru-facet',
+        'wrapper' => 'mkdru-facets-form-wrapper',
+      ),
+    );
   }
   $form['new_facet']  = array(
     '#type' => 'fieldset',
@@ -268,6 +278,13 @@ function mkdru_add_facet_submit($form, &$form_state) {
   return $form_state['values'];
 }
 
+function mkdru_remove_facet_submit($form, &$form_state) {
+  dpm($form_state);
+  $delfacet = $form_state['clicked_button']['#mkdru facet'];
+  if ($delfacet)
+    unset($form_state['values']['settings']['facets'][$delfacet]);
+}
+
 function mkdru_add_facet_callback() {
   // Necessary to work with hook_form
   module_load_include('inc', 'node', 'node.pages');