Skip to content

Commit

Permalink
going back to the old way of validating model data (Closes #728)
Browse files Browse the repository at this point in the history
  • Loading branch information
janhartigan committed Nov 2, 2014
1 parent 56fe7fb commit 0eda9b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Changelog

- Bugfix: when validating all rules against all attributes for existing models, "exists" and "unique" rules would cause problems

### 4.14.0
- New translations (hr, nb)
- Bugfix: The Spanish translation had an issue with noun genders
Expand Down
6 changes: 5 additions & 1 deletion src/Frozennode/Administrator/Config/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,11 @@ public function save(\Illuminate\Http\Request $input, array $fields, array $acti
$this->fillModel($model, $input, $fields);

//validate the model
$validation = $this->validateData($model->getAttributes(), $this->getModelValidationRules(), $this->getModelValidationMessages());
$data = $model->exists ? $model->getDirty() : $model->getAttributes();
$rules = $this->getModelValidationRules();
$rules = $model->exists ? array_intersect_key($rules, $data) : $rules;
$messages = $this->getModelValidationMessages();
$validation = $this->validateData($data, $rules, $messages);

//if a string was kicked back, it's an error, so return it
if (is_string($validation)) return $validation;
Expand Down

0 comments on commit 0eda9b3

Please sign in to comment.