You are here

function hs_content_taxonomy_form_submit in Hierarchical Select 6.3

Submit handler for HS CT field form

1 string reference to 'hs_content_taxonomy_form_submit'
hs_content_taxonomy_form_alter in modules/hs_content_taxonomy.module
Implementation of hook_form_alter().

File

modules/hs_content_taxonomy.module, line 70
Implementation of the Hierarchical Select API for the Content Taxonomy module.

Code

function hs_content_taxonomy_form_submit(&$form, &$form_state) {
  foreach ($form['#field_info'] as $field_name => $field_info) {
    if ($field_info['widget']['type'] == 'content_taxonomy_hs') {

      // Change format of values to the one Content Taxonomy expects
      if (is_array($form_state['values'][$field_name]['tids'])) {
        $values = array();
        foreach ($form_state['values'][$field_name]['tids'] as $tid) {
          $values[] = array(
            'value' => $tid,
          );
          array_unshift($form_state['values'][$field_name], array(
            'value' => $tid,
          ));
        }
        $form_state['values'][$field_name]['tids'] = $values;
      }
      else {
        $values[] = array(
          'value' => $form_state['values'][$field_name]['tids'],
        );
        array_unshift($form_state['values'][$field_name], array(
          'value' => $form_state['values'][$field_name]['tids'],
        ));
        $form_state['values'][$field_name]['tids'] = $values;
      }
    }
  }
}