Posts: 8
Threads: 1
Joined: May 2009
Reputation:
0
Hey all,
Great script, really impressed and so much potential.
Got a couple of can yous with it though.
1. Can you have a hidden field on the form that automatically populates with the username who is filling in the form?
2. Using above apply a filter so that the user can only see submissions for them?
3. Part of our form also asks for a Town/City, and we will have certain people in that town that will need to see those results, but only for their town, can we do that as well?
Cheers
Brad
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Hey Brad,
Quote:1. Can you have a hidden field on the form that automatically populates with the username who is filling in the form?
Yes, but you'll need to use the Submission Pre-Parser module. This module lets you add custom PHP code to process the incoming info and - pretty much - do whatever the heck you want with it. So in this case, you'd add a rule that just did this:
PHP Code: $_POST["my_hidden_field"] = $_POST["username"];
It's pretty much that simple.
Quote:2. Using above apply a filter so that the user can only see submissions for them?
Yes... but I'd like to hear a few more details to confirm we're on the same page, first. If I understand you write, you'd have multiple users (or "clients" in FT terminology). They'd each have a client account set up. They'd be the ones filling in the forms (correct?) [in which case, you'd need to tweak the above example I gave for #1 to pull the account info from sessions - but the principle is the same].
Quote:3. Part of our form also asks for a Town/City, and we will have certain people in that town that will need to see those results, but only for their town, can we do that as well?
Yes (he says tentatively), but again I'd need a few more details. You can set up client accounts to view whatever subset of the information that you want. So you could, for example, set up a View that only shows submissions for a particular user and for a particular town/country. This is no problem - but note that it's NOT dynamic (i.e. you can't create these data subsets on the fly), you'd need to create each account manually that would view the appropriate data.
Man, that sounded clearer in my head. Let me know if I can make it sound any more confusing.
- Ben
Posts: 8
Threads: 1
Joined: May 2009
Reputation:
0
Ben
You pretty much got what I am trying to do, and with a bit of research yesterday I think I am on the right track, our form is a 3 page form, and on one form are two fields that use autocomplete with a wizzy java script. The easiest way I found to get the two working was to split the form, and have a confirm button for the first field that actually submits the form and loads a second looking the same. I then used the @fields strings to pre-populate the info again so to the user it does not look like another page.
I will add a hidden field to the form that grabs their username/id and then use that in the filtering for that user?
For the town filtering do the same?
Really exited now, things are looking good, and really love how flexible this is, nice work!
Posts: 8
Threads: 1
Joined: May 2009
Reputation:
0
Ben have tried what you said about using the pre-parser and nothing is being added, any further advice?
Posts: 8
Threads: 1
Joined: May 2009
Reputation:
0
Managed to get it to pass the username by using this
$username = $_SESSION['ft']['account']['username'];
on the form, then using the echo to put the value in the hidden field.
Posts: 8
Threads: 1
Joined: May 2009
Reputation:
0
Only trouble I am having now if anyone has any suggestions? The above works on the form to pass back the username in a field, and it appears in the results in admin view.
What I want to do is add a view filter for the users so that it compares that value with their username and only returns matching results.
Any ideas? Have tried putting the session string in the value of the filter, but that returned nothing.
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Hey Brad,
Sorry for the long wait. Darn day job!
Quote:What I want to do is add a view filter for the users so that it compares that value with their username and only returns matching results.
Hmm... this is trickier... This was actually what I was warning about when I said it wasn't "dynamic". There's currently no way to feed in values from the logged in user to the View feature. Each user has to be manually hardcoded.
But you're not the first person to request this feature so let me give it some thought. If I haven't written back in the next few days send an angry email to formtools@encorewebstudios.com. It may well be impossible for the time being, but I need a little time to think it all through.
- Ben
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Heya,
Actually, I just spent some time looking over the code and can give a definitive "no" to this particular feature for the moment.
What needs to be done is expand the dropdowns on the View filters page to include a new section for users - not just the form fields. Anything other would be a terrible hack. And unfortunately this is no small change...
Sorry I couldn't help on this feature just yet.
- Ben
Posts: 8
Threads: 1
Joined: May 2009
Reputation:
0
Ben I am not saying I am a wiz at coding, far from it, but pick things up fast, before 2 weeks ago never created pages with java or mysql queries, and done both with ajax, and works really well.
Perhaps I could create a custom page and add it to the users drop down and then hack the template to remove the view option? At least thats what I was thinking as a back up.
|