This patch adds support for using the jQuery Placeholder plugin, plus adds some useful features such as:

  • Ability to use the #title field as the placeholder text (#placeholder = TRUE or custom label)
  • Ability to hide the label element via JavaScript (#placeholder_label_hidden = TRUE)
  • Support older browsers that don't support the placeholder attribute

Required the libraries module and https://github.com/danielstocks/jQuery-Placeholder. Just save the plugin as jquery.placeholder.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bleen’s picture

This looks really good ... a couple of things before I would commit this:

a) It needs an hook_requirements function that checks for "libraries" and the jQuery-placeholder plugin
b) there are several (very) minor whitespace issues in the patch. Example:

+++ b/placeholder.jsundefined
@@ -1,5 +1,15 @@
+    ¶

white space

This is a great improvement though.

Powered by Dreditor.

bleen’s picture

Status: Needs review » Needs work

status

funkym’s picture

Status: Needs work » Needs review
FileSize
5.52 KB
funkym’s picture

Looks like the plugin needs at least jQuery 1.3.2, so we'll need to add jquery_update as a dependency.

bleen’s picture

It appears this patch is not working when you use

#placeholder => t('some text')

instead of

#placeholder => TRUE,
#title => t('some text'),
bleen’s picture

Status: Needs review » Needs work
funkym’s picture

This patch seems to be working for me, maybe the module system weights need to be adjusted?

mariacha1’s picture

The link to the repo for the jquery code on github is broken.

https://github.com/danielstocks/jQuery-Placeholder

Any chance the file is somewhere else?

damiankloip’s picture

Hmm, it looks like it's been moved, maybe to https://github.com/akirk/jQuery-Placeholder..

I will have to change the docs for the 7.x branch to reflect this.

stewart.adam’s picture

Using this library worked for me: https://github.com/mathiasbynens/jquery-placeholder