You are here

function custom_add_another_process_file_buttons_labels in Custom add another 8

Process element callback for multiple Managed file widgets.

1 string reference to 'custom_add_another_process_file_buttons_labels'
custom_add_another_field_widget_form_alter in ./custom_add_another.module
Implements hook_field_widget_form_alter().

File

./custom_add_another.module, line 151
Allows the 'Add another item' button text to be customised.

Code

function custom_add_another_process_file_buttons_labels($element, FormStateInterface $form_state, $form) {
  if (isset($element['#custom_add_another_value']) || isset($element['#custom_remove'])) {
    if (isset($element['#custom_add_another_value']) && isset($element['upload_button']['#value']) && $element['upload_button']['#value'] != t($element['#custom_add_another_value'])) {
      $element['upload_button']['#value'] = t($element['#custom_add_another_value']);
    }
    if (isset($element['#custom_remove']) && isset($element['remove_button']['#value'])) {
      $element['remove_button']['#value'] = t($element['#custom_remove']);
    }
  }
  return $element;
}