I installed the very nice form-extra plugin for the double list
feature. However, I noticed it didn't preselect values properly when
your choices are represented by a multi-dimensional array (for
organization). This is basically because the double list widget does
not recursively read your choices array.

I found a function in the php documentation comments designed to
flatten an array, and doing this to your choices array for the widget
works like a charm.

Simply call the function in the double list plugin widget around line
114, right before the foreach loop, feeding your flattened array
instead of your original one. Here is the semi-compressed function:

function array_flatten($a, $f = array())
  {
    if (!$a || !is_array($a)) return '';

    foreach ($a as $k=>$v) {
      if (is_array($v)) $f = array_flatten($v, $f);
      else $f[$k] = $v;
    }

    return $f;
  }

Now you can chunk up your choices to your hearts content and still use
the double list feature.

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to