public function hashToFieldValue($fieldValue, array $context = array())
    {
        if ($fieldValue === null) {
            return new SelectionValue();
        }

        // allow user to pass in a single value
        if (is_string($fieldValue) || is_int($fieldValue)) {
            $fieldValue = array($fieldValue);
        }

        // allow user to pass in selection values by name
        $fieldSettings = null;
        foreach($fieldValue as $key => $val) {

            $val = $this->referenceResolver->resolveReference($val);

            if (is_string($val)) {
                if (ctype_digit($val)) {
                    $fieldValue[$key] = (int)$val;
                } else {
                    if ($fieldSettings === null) {
                        $fieldSettings = $this->loadFieldSettings($context['contentTypeIdentifier'], $context['fieldIdentifier']);
                    }
                    foreach($fieldSettings['options'] as $pos => $name) {
                        if ($name === $val) {
                            $fieldValue[$key] = $pos;
                            break;
                        }
                    }
                }
            }
        }

        return new SelectionValue($fieldValue);
    }