Unique value validation not working

varst

Member
I have a form with a repeated group. I have a field (any field) with a validation element "isuniquevalue", but it's not working. On save I have error message: "Error: 1054. Unknown column 'Array' in 'where clause'"
 
Please post screen shots of the validation tab. What type of element i.e. what element plugin is it?
 
Try changing line 104 of plugins/fabrik_validationrule/isuniquevalue/isuniquevalue.php from
PHP:
$rowId = $this->formModel->formData[$pk];
to
PHP:
$rowId = $this->formModel->formData[$pk][$repeatCounter];
I'm not really sure if it ever needs to be checked that $this->formModel->formData[$pk] is already an array.
If so this line might be the better replacement?...
PHP:
$rowId = (is_array($this->formModel->formData[$pk])) ? $this->formModel->formData[$pk][$repeatCounter] : $this->formModel->formData[$pk];

Hopefully Hugh will see this and he can decide - otherwise I'd change it myself at Github.
 
Try changing line 104 of plugins/fabrik_validationrule/isuniquevalue/isuniquevalue.php from
PHP:
$rowId = $this->formModel->formData[$pk];
to
PHP:
$rowId = $this->formModel->formData[$pk][$repeatCounter];
I'm not really sure if it ever needs to be checked that $this->formModel->formData[$pk] is already an array.
If so this line might be the better replacement?...

Hopefully Hugh will see this and he can decide - otherwise I'd change it myself at Github.

It really works!
Thank you very much!
 
OK, @Bauer - can you test this:

https://github.com/Fabrik/fabrik/commit/cd44bb5272ec443c575e565f8b9383ca5dbdc079

I did some basic testing, which seem to work, although there's probably some more work needs doing.

@varst - be careful with that modification, as there are configurations where that will error out. Also, it won't pick up cases where they have added or modified repeat data (ie. added a new repeat, and changed an existing one so it's a dupe of the new one). I suggest you try the github update I just committed. See wiki for updating from github.

NOTE - I've also added an option, "Within Group", which restricts the uniqueness test to just "this" form's repeats. So it doesn't look at the database, just makes sure that there's no duplicated value in the repeats of that group on this form.

I also now run that same test (within group) even if you haven't selected that option, as it'll pick up cases where they have added/modified repeat data and introduced a duplicate, which won't show up with a simple lookup on the existing data in the table. So with the new option set to "no", it runs the 'within group' test first, to make sure the submitted data is unique, before testing against the database. If set to 'yes', it only runs the 'within group' test.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top