Hackery, Math & Design

Steven Wittens i

fQuery Sneak Preview

Update: fQuery has been released.

Here's a sneak preview of something I've been working on since DrupalCon Brussels...

I've noticed that most hook_form_alter() uses need to look for certain elements in the $form array. For example, you want to make all resizable textareas fixed height. This means you have to iterate over $form and do recursion, find the matching elements and change them. That sucks.

What if you could just find all elements with certain properties with one line of code, and do stuff with them? Doesn't this sound at all familiar?

Enter fQuery. In a hook_form_alter(), you could do:

$query = f('textarea.resizable', $form);
foreach ($query as &$element) {
  $element['#resizable'] = FALSE;

Neat huh?

Drupal  FAPI  fQuery  jQuery
This article contains graphics made with WebGL, which your browser does not seem to support.
Try Google Chrome or Mozilla Firefox. ×