dpm($form_state);
// dpm($settings);
if (isset($form_state['values']['settings'])) {
- $settings = $form_state['build_info']['args']['settings'];
+ $settings = $form_state['values']['settings'];
}
else if (isset($form_state['build_info']['args']['settings'])) {
$settings = $form_state['build_info']['args']['settings'];
'#tree' => TRUE,
);
- $form['settings']['title'] = array(
- '#type' => 'textfield',
- '#title' => t('Search title'),
- '#required' => FALSE,
- '#default_value' => $settings['title'],
- '#weight' => -5
- );
-
$form['settings']['pz2_path'] = array(
'#type' => 'textfield',
'#title' => t('Pazpar2/Service Proxy path'),
'#collapsible' => TRUE,
'#collapsed' => FALSE
);
- if (empty($form_state['facet_names'])) {
- $form_state['facet_names'] = array('source', 'author', 'subject');
- }
- foreach ($form_state['facet_names'] as $facet) {
+
+ foreach (array_keys($settings['facets']) as $facet) {
$form['settings']['facets'][$facet] = array(
'#type' => 'fieldset',
'#title' => $facet . ' ' . t('facet'),
'#maxlength' => 3,
);
}
+
$form['new_facet'] = array(
'#type' => 'fieldset',
'#title' => t('Add new facet...'),
* Implements hook_form()
*/
function mkdru_form(&$node, &$form_state) {
-// Can't use the node type's title since
-// merging AJAX forms is currently beyond me.
-// $type = node_type_get_type($node);
-// Title would be: check_plain($type->title_label);
if (isset($node->mkdru->settings)) {
// Second decode parameter indicates associative array
$form_state['build_info']['args']['settings'] = json_decode($node->mkdru->settings, TRUE);
}
- return drupal_retrieve_form('mkdru_settings_form', $form_state);
+ $form = drupal_retrieve_form('mkdru_settings_form', $form_state);
+ $type = node_type_get_type($node);
+ $form['title'] = array(
+ '#type' => 'textfield',
+ '#title' => check_plain($type->title_label),
+ '#required' => FALSE,
+ '#default_value' => $node->title,
+ '#weight' => -5
+ );
+ return $form;
}
function mkdru_add_facet_form($form, &$form_state) {
- $form_state['facet_names'][] = $form_state['values']['new_facet']['canonical'];
+ // TODO: validation
+ $newfacet = $form_state['values']['new_facet']['canonical'];
+ $form_state['values']['settings']['facets'][$newfacet] = NULL;
$form_state['rebuild'] = TRUE;
}