The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
Setting field default value to client-related data - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1) +--- Forum: General Discussion (https://forums.formtools.org/forumdisplay.php?fid=5) +--- Thread: Setting field default value to client-related data (/showthread.php?tid=14411) |
Setting field default value to client-related data - gotty - Aug 9th, 2016 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???? RE: Setting field default value to client-related data - gotty - Aug 10th, 2016 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). RE: Setting field default value to client-related data - ADaniel - Sep 2nd, 2016 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. |