/**
  * Saves or updates the model form
  *
  * @return mixed Returns the primary key of the new/updated record or
  * returns false if the form data is not valid
  */
 public function save()
 {
     if ($this->isValid()) {
         $fields = $this->model->modelFields();
         foreach ($fields as $name => $field) {
             if (isset($this->fields->{$name})) {
                 if (!$field->getAuto()) {
                     $method = sprintf('set%s', $name);
                     $label = sprintf('%s_%s', Field::FIELD_NAME_PREFIX, $name);
                     if (get_class($field) == 'ORM\\Field\\IntegerField') {
                         $this->model->{$method}(intval($this->fields->{$name}->getValue()));
                     } elseif (get_class($field) == ModelField::class) {
                         $getMethod = sprintf('get%s', $name);
                         $pk = $this->model->{$getMethod}()->getPK();
                         $setMethod = sprintf('set%s', $pk['name']);
                         $this->model->{$getMethod}()->{$setMethod}(intval($this->fields->{$name}->getValue()));
                     } else {
                         $this->model->{$method}($this->fields->{$name}->getValue());
                     }
                 }
             }
         }
         return $this->model->save();
     }
     return false;
 }