Because the <i class="icon glyphicon glyphicon-filter" aria-hidden="true"></i> is added before the word Filter in the submit button in the translation interface (admin/config/regional/translate/translate), the form is not working properly.

This is because to know what to do the function uses the literal in the submit button, and because this prefix is added is not working.

How can I disable it?

Comments

gabidrg’s picture

I fixed this the fast way by reimplementing a process callback in my theme template.php. This is not an ideal solution, but fixed the issue.

/**
 * Implements hook_element_info_alter().
 *
 * Alter some Bootstrap process callbacks
 */
function my_theme_element_info_alter(&$elements) {
  foreach ($elements as &$element) {
    // Process all elements.
    $element['#process'][] = '_my_theme_process_element';
  }
}

Then the process callback included an exception array based on form_id:

/**
 * Process all elements.
 */
function _my_theme_process_element(&$element, &$form_state) {
  $exceptions = array(
    'locale_translation_filter_form',
  );
  $form_id = isset($form_state['build_info']['form_id']) ? $form_state['build_info']['form_id'] : '';

  if (!empty($element['#attributes']['class']) && is_array($element['#attributes']['class'])) {
    $key = array_search('container-inline', $element['#attributes']['class']);
    if ($key !== FALSE) {
      $element['#attributes']['class'][$key] = 'form-inline';
    }
    if (in_array('form-wrapper', $element['#attributes']['class'])) {
      $element['#attributes']['class'][] = 'form-group';
    }
  }
  // Process form actions.
  if (!empty($element['#type']) && $element['#type'] === 'actions') {
    foreach (element_children($element) as $child) {
      if (!in_array($form_id, $exceptions)) {
        _bootstrap_iconize_button($element[$child]);
      }
    }
  }
  // Automatically inject the nearest button found after this element if
  // #input_group_button exists.
  if (!empty($element['#input_group_button'])) {
    // Obtain the parent array to limit search.
    $array_parents = array();
    if (!empty($element['#array_parents'])) {
      $array_parents += $element['#array_parents'];
      // Remove the current element from the array.
      array_pop($array_parents);
    }
    // If element is nested, return the referenced parent from the form.
    if (!empty($array_parents)) {
      $parent = &drupal_array_get_nested_value($form_state['complete form'], $array_parents);
    }
    // Otherwise return the complete form.
    else {
      $parent = &$form_state['complete form'];
    }
    // Ignore buttons before we find the element in the form.
    $found_current_element = FALSE;
    foreach (element_children($parent) as $child) {
      if ($parent[$child] === $element) {
        $found_current_element = TRUE;
        continue;
      }
      if ($found_current_element && _bootstrap_is_button($parent[$child])) {
        _bootstrap_iconize_button($parent[$child]);
        $element['#field_suffix'] = drupal_render($parent[$child]);
        break;
      }
    }
  }
  return $element;
}
markhalliwell’s picture

markhalliwell’s picture