Temp

Pets
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

Pets
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-atomic
aria-busy (state)
aria-controls
aria-describedby
aria-disabled (state)
aria-dropeffect
aria-flowto
aria-grabbed (state)
aria-haspopup
aria-hidden (state)
aria-invalid (state)
aria-label
aria-labelledby
aria-live
aria-owns
aria-relevant

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) {

Pages

Subscribe to Mick's Playground RSS