public function getModel() {
        if (!$this->model)
            return null;

        $data = $this->data;
        if ($this->isValid() && $this->model) {
            foreach ($this->fieldsets as $name) {
                if (!isset($this->elements[$name]))
                    continue;

                $fieldset = $this->elements[$name]->options->value;
                $fieldsetModel = $fieldset->getModel();
                $data[$name] = $fieldsetModel ? $fieldsetModel : $fieldset->getData();
            }
            $this->model->populate($data);
        }

        return $this->model;
    }