protected function doBuild($type, $name, $value = null, array $attributes = array(), array $extra = array(), $options = null)
    {
        $attributes = $this->replaceAttributes($attributes);

        if (!$this->checkAccess($attributes)) {
            return '';
        }

        $required = $this->getRequired($attributes);
        $label = $this->getLabel($name, $attributes);
        $htmlName = $this->getHtmlName($name);
        $id = $this->getHtmlId($name, $attributes);
        $errors = $this->getControlErrors($name);
        $hasErrors = !empty($errors);
        $customTemplate = $this->getCustomTemplate($attributes);

        $attributes = $this->getHtmlAttributes($type, $attributes, $errors, $id);

        $input = $this->buildControl($type, $name, $value, $attributes, $options, $htmlName, $hasErrors);

        return $this->theme->render(
            $customTemplate,
            array_merge($extra, compact('htmlName', 'id',  'label', 'input', 'errors', 'hasErrors', 'required')),
            'fields.'.$this->getDefaultTemplate($type)
        );
    }