Views integration for filtering
Amitaibu - February 19, 2008 - 13:38
| Project: | Unique field |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Thanks for the awesome module. Would be nice if in the scope of unique values admin will be able to filter the results according to a views - like in the CCK nodereference

#1
For that matter, I think Views should be used to determine uniqueness. The majority of this module is query-building code. Drupal already has a query builder: Views. This would not only remove the current limitation to CCK fields and mean you automatically support any fields that have Views integration, but would also open the module up to imposing uniqueness constraints on things other than nodes.
The way I think it might work would be to define a new Views display type ("Uniqueness", or something). When a node (or user, or taxonomy term...) form submission is being validated, any relevant "Uniqueness" views are executed, using values from the form submission in the view arguments. If any results are returned, the form doesn't validate.
I haven't worked much with the Views 2 API (don't think it's worth backporting to Views 1), but I think this approach is feasible, and would clean up most of the issues currently in the queue. Would also clean up your UI code, as you'd be mostly using the Views UI.
Would like to work on this myself, but won't have time for quite a while. :(