This is a great module and has saved me hours of work implementing AHAH file uploads. However, I need a little more customisation than this module is prepared to give. I want to be able to specify the text that appears on the upload buttons. The string 'Update' is too generic for use on my site.

CommentFileSizeAuthor
#1 upload_element-button-text.patch563 bytesmrfelton

Comments

mrfelton’s picture

StatusFileSize
new563 bytes

Attached patch does fine for me, along with this code:

   $form['details']['cv_upload'] = array(
    '#type' => 'upload_element',
    '#title' => t('Attach your CV'),
    '#required' => TRUE,
    '#file_validators' => array(
      'file_validate_size' => array(1048576),
      'file_validate_extensions' => array('doc odf pdf txt rtf'),
    ),
    '#button_text' => array(
      'update' => 'Attach',
    )
alan d.’s picture

Title: Ability to rename buttons » Howto #1: Rename the Update button
Version: 6.x-1.x-dev » 6.x-1.1
Status: Active » Closed (works as designed)

Thanks Tom

Rather than adding more options, there is a workaround using the element FAPI property #after_build.

So change the element definition to include this property:

Eg:

<?php
  $form['book_cover'] = array(
    '#type' => 'image_upload_field',
    '#title' => t('Book cover'),
    '#required' => FALSE,
    '#default_value' => $node->book_cover,
    '#after_build' => array('test_after_build'), // Same rules as #submit, #valdate, etc
  );
?>

And then define the function somewhere in the included paths:

<?php
function test_after_build($form, $form_state) {
  $form['image_upload_field']['#value'] = 'test_after_build';
  return $form;
}
?>