0

i need to style the input[type="file"], the only way to really style them is to add a <label> which has the same for value as the input's id. Drupal does not provide a correct label in single input[type="file"] upload and even no label in multiples input[type="file"] uploads. Is there any way to solve this issue?

Thanks

2

The markup in Drupal is always overridable. In this case, you may either need to use a hook_form_alter() in a custom module to modify the label html, override the theme_file() theme function (which is responsible for producing the markup for the file input element), or theme the form specifically. Any of these three methods should be able to meet your needs (although I'm partial to the theme_file() approach).

| improve this answer | |
  • Many thanks coreyp, i used the theme_file() theme function. Its works with single and multiple file uploads, just need to add <label for="' . $element['#attributes']['id'] . '">Text</label> – Federico Arena Jul 29 '14 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.