protected function extractKeyAndCollection($str)
{
if (strpos($str, '[') === false) {
return array(null, $str);
}
// this is a devise tag for a collection
$collection = null;
$key = null;
$parts = explode('[', $str);
if (count($parts) > 1) {
$collection = array_shift($parts);
$nextPart = count($parts) > 0 ? explode(']', $parts[0]) : array();
$key = count($nextPart) > 0 ? array_shift($nextPart) : null;
}
return array($collection, $key);
}