Pet's Number Pet's Name Species Age
Pet 1
Pet 2

Comparison of WCAG compliant links

(as seen by someone with color blindness)

2px Border-bottom

Legends and fieldsets

Name Species Age
Cassie Canine 6
Cooper Feline 1

WAI-ARIA Global Properties

These can be applied to all HTML elements, regardless of whether a role is used.

aria-busy (state)
aria-disabled (state)
aria-grabbed (state)
aria-hidden (state)
aria-invalid (state)

Autocomplete By Zip Code

The admin of a Drupal site enters and updates many addresses every day. For every contact and organization account on their site, they have a city, state, zip code, county, and region. Really, the address fields are just redundant information. Everything can be gleaned from the zip code. So, in an effort to become more efficient and reduce data entry errors, the client requested that the city, state, county, and region fields autocomplete by entering the zip code.

Encrypting Fields on an Entity

Recently, a client had a need to store social security numbers in a Drupal site.  It wasn't the full SSN, just the last 4 digits, but I still wasn't comfortable storing it in plain text in case the database (God forbid!) was ever compromised.

Sanitize emails in db

drush sqlq "UPDATE users SET mail = concat('myaddr+', replace(mail, '@', '_'), '@testdomain.org') WHERE uid > 0 AND instr(mail, '@testdomain.org') = 0;" && drush upwd --password=password admin

Pre-commit hook that checks for debug code

Run this on all repos - it adds a pre-commit hook to Git that checks for dpm statements, debug code, and things that probably shouldn't be committed to repos.

curl -fsSL http://gitscripts.s3.amazonaws.com/install | php

Returns a map of field names and vocabularies they can reference

function _get_tax_term_fields_map() {
  static $map;
  if (isset($map)) {
    return $map;

  // First, find all taxonomy term fields.
  foreach (field_info_fields() as $field) {
    if ('taxonomy_term_reference' === $field['type']) {
      $all[] = $field;

  // Next, build a map, keyed by the field name.
  foreach ($all as $field) {
    foreach ($field['settings']['allowed_values'] as $vocab_info) {


Subscribe to Mick's Playground RSS