protected function getMagentoProperty($key, $value, $type)
    {
        switch ($key) {
            // Fields to ignore:
            case 'type':
            case 'id':
            case 'fields':
                $result = array();
                break;
            case 'summary':
                $result = array('legend' => $value);
                break;
            // Fields to return unchanged:
            case 'legend':
            case 'label':
            case 'format':
                $result = array($key => $value);
                break;
            case 'name':
                if ($type === 'checkbox') {
                    // Make it an array for PHP POST processing, in case there
                    // are multiple checkboxes.
                    $value .= '[]';
                }
                $result = array($key => $value);
                break;
            case 'description':
                // The description of a fieldset is handled elsewhere.
                $result = $type !== 'fieldset' ? array('after_element_html' => '<p class="note">' . $value . '</p>') : array();
                break;
            case 'value':
                if ($type === 'markup') {
                    $result = array('text' => $value);
                } else { // $type === 'hidden'
                    $result = array('value' => $value);
                }
                break;
            case 'attributes':
                // In magento you add pure html attributes at the same level as
                // the "field attributes" that are for Magento.
                $result = $value;
                if (!empty($value['required'])) {
                    if (isset($result['class'])) {
                        $result['class'] .= ' ';
                    } else {
                        $result['class'] = '';
                    }
                    if ($type === 'radio') {
                        unset($result['required']);
                        $result['class'] .= 'validate-one-required-by-name';
                    } else {
                        $result['class'] .= 'required-entry';
                    }
                }
                break;
            case 'options':
                $result = array('values' => $this->getMagentoOptions($value));
                break;
            default:
                $this->log->warning(__METHOD__ . "Unknown key '$key'");
                $result = array($key => $value);
                break;
        }
        return $result;
    }