Posts: 2
Threads: 1
Joined: Aug 2016
Reputation:
0
Aug 9th, 2016, 8:33 AM
(This post was last modified: Aug 9th, 2016, 8:33 AM by gotty.)
I need to filter form views so that one client can only add/edit their records.
The Client Map Filter seems to be what would do this, and I can see how to use a form field to match the client field to limit what can be viewed.
But that's really not much use as any client could change the field value to see others' data - and if they get it wrong, they wouldn't see theirs.
So, basically, how can a form field be automatically filled with client-specific data????
Posts: 2
Threads: 1
Joined: Aug 2016
Reputation:
0
Aug 10th, 2016, 5:13 AM
(This post was last modified: Aug 10th, 2016, 5:14 AM by gotty.)
Since there hasn't been any reply, I've managed (after many hours of work with the PHP code) to solve this.
I created a field (let's say client_id) in the form, which is made uneditable in the clients' view, and set the Client Map Filter to filter on match client_id = ID
Then, in submissions.php added a line in the create_blank_submission function that added the account_id to the client_id field when the submission was created.
Now, whenever a submission is created, the client_id is set to the account's ID number so I know who created the entry, and the filter will not allow that client to edit the field.
Of course, the field is editable by the admin and I plan to add a little sophistication in the future that will allow admin to make an individual record viewable (and so editable) to any clients by adding their ID to the client_id field (needs care in designing the logic of course).
Posts: 37
Threads: 7
Joined: Dec 2014
Reputation:
0
This is basically how I solved this issue as well. On one site, there are different categories of clients, and each category can see either their own forms or their own plus others whom they supervise. I can create a View filter because I wrote code that places the Client ID's automatically into the forms, in fields uneditable by the clients themselves. However, instead of modifying the submission.php file, I installed the Submission Pre-Parser Module, and put code in it to update the Submission by adding the Client's ID, and their supervisor's Client ID (looked up from another Form), when the form is first submitted. By using this module for this type of coding, my code won't disappear or have to be rewritten if FormTools has an upgrade.