Address on Zend_Form using Google Maps API - zend-framework

So I'm new to both Zend and to Google Maps API, I want to create a form. Where the user inputs an address in a field (probably an field completely outside of the "form") the address is being looked up on google maps, preferably realtime but could also be done with a "search address" button. When user is happy with shown address, he submits form and address (or long/lat, whatever is best) is extracted from google map api and saved along with additional form data to database. How would this be done in the best way?

The easiest way would be to add two hidden fields to your form (lat/long) and handle the textfield in javascript. So when the user finished typing the address you start an ajax-request and write the resulting lat / long values in the hidden fields.
When submitted you should check the form and look for filled values in the lat / long fields. If they are missing show an error message to the user.

Related

Is there a way to create an output form based on Google Sheets data?

What I want to make
Is this possible?
I'd like to create an output form that reads data from a Google Sheets spreadsheet. In the form, users would enter a few values (entering their name and some ID number, for example) and view the corresponding information in the connected spreadsheet but not any other information in the sheet. Something like an output form in Microsoft Access. I'm hoping there's a way to accomplish this in Google Sheets using existing tools and maybe some scripting.
More generally, though, any way to create this type of 'limited visibility' on a per-user basis for Google Sheets data would be useful. (The 'protect sheet' function in the menu doesn't accomplish this; see below.)
For reference, my specific use case at the moment is as a teacher and wanting a way for students to see specific information related to them from my student information spreadsheet but while not revealing other students' information. I would have a simple form where they enter a name and maybe some personalized code that I give them so they can see their attendance record or something else. For my purposes, I don't need the form to be extremely secure as none of the information is all that sensitive (although more secure is better), but I don't want to be just putting all the information there in front of them by giving them access to the entire sheet.
What I've tried so far
I made a new spreadsheet file with two sheets; one sheet was visible to function as a form, and the second sheet was not visible (which I accomplished via the 'protect' menu option). I used importrange() to read in the relevant data from my primary spreadsheet to the new spreadsheet's non-visible sheet. On the visible sheet, students entered their name from a drop-down and entered their student ID as validation. If the student's name and ID matched, the first sheet did a vlookup() to read in information from the protected sheet and some information from their student record.
Here's what I made, in case my description doesn't make sense: https://drive.google.com/open?id=1cHO2jzMh1mkXvlLh-M4eYqN7v11t95-GnfWqL5IwQ14&authuser=0
This had two problems, one small and one big.
The small problem was that every student could see the "form" sheet at the same time. If two students opened the spreadsheet at the same time they would see any information that the other student had entered. I handled this by writing a simple script to automatically reset the "form's" input cells after 20 seconds. Also, any time the form was opened by a new person, the "form's" output cells were erased. So, obviously not a brilliant solution, but for my purposes, this was mostly good enough.
The big problem was that Google's own preview viewer (built into Google Drive and the like) ignores protected ranges and sheets and displays the entire contents a spreadsheet. (Normally, protected sheets are not visible at all and don't appear in the list of sheets at the bottom of the screen unless the viewer has access to them.)
In my case this meant included the protected one that shouldn't have been visible at all, rendered as if it were a print preview, meaning the students were actually able to view all of the other students' data in one big table.
Are you familiar with Web Apps?
An Apps Script Web App allows you among others to output selected Google Document contents into a browser.
Hereby, you can use the method Session.getActiveUser() to obtain the email of the user and dynamically adjust the data the user is going to obtain in function of his email (BTW, you can also use Session.getActiveUser() in the spreadsheet, to detect the user automatically instead of asking him for his name).
Simple example workflow:
Replace in column A student names through student emails (the Gmail addresses with which the users authenticate their sessions and access Google Sheets)
Bind to the spreadsheet a script with a content similar to the following:
function doGet(){
var ss=SpreadsheetApp.getActive().getSheetByName('Data');
var range=ss.getDataRange();
var values=range.getValues();
var user=Session.getActiveUser();
var output="";
for(var i=1;i<ss.getLastRow();i++){
if(values[i][0]==user){
for(var j=1;j<ss.getLastColumn();j++){
output+=(values[i][j])+" ";
}
}
}
return ContentService.createTextOutput(JSON.stringify(output));
}
Make sure that you have a doGet() function and a return statement.
After running the script once manually to trigger authorization flow, deploy it as a Web App - executing it as User accessing the web app and giving access to Anyone (unless desired otherwise).
Copy the URL of your WebApp and forward it to your student.
When the student open the URL in their browser - they will obtain their results - provided their email is listed in the sheet.
Please note that the code provided is a simple sample, that retrieves
all data and outputs it as a string. Feel free to modify the script
e.g. retrieving only columns of interest and outputting the data as a
html table, rather than a simple string.

Place Autocomplete Address Form

I created a registration form for a website and I included the Place Autocomplete Address Form provided by Google to fill the Country, Province and City fields.
It works perfectly. However, I use Google Analytics and I have seen that a certain number of users leave the process before completing the registration, as if something went wrong and couldn’t complete it.
The form itself is quite simple, so I checked it with some possible errors.
It has several requested fields, so the form reloads partially to display a popup asking you to add the information or data in each case. The fields filled out correctly keep de information. All but the ones filled out by the Google API, which simply disappear. And I am not talking about the information added to them, the fields themselves are missing, removed from the code.
Any suggestion?
I created a registration form.
Some fields (Country, Province and City) are filled by this API:
Place Autocomplete Address Form
The code I used is on that page.
If you fill out the form and make any mistake or fail to fill any requested field, for instance, adding different passwords in the Password and Re-write Password fields, the form realoads partially displaying a message requesting you to fill them properly.
By them, the fields to be filled by the Google API are gone, removed from the code.
The problem is that when the user filled the, in the example, password and re-write password fields properly, another message popups requesting to fill the country, province and city fields.
Is it clear enough now?

Using ninja forms, how can I persist field values across pages?

I have a form on the home page of quotedjobs.com that I would like to persist the field values of across pages.
For example: A user enters some values in fields, such as job title (textbox), job type (list) and job description (text field). Underneath that I ask users to register on the site, but they have the option to click a link to allow them to login if they are already members.
What I would like to be able to do, is to redirect users to another form that is a copy, but allows them to login instead of register, but keep hold of the values that they entered in the title, type and description form of the previous page so they aren't losing their work.
I have seen the ninja_forms_processing variable in the docs, but I'm not clear on how to use that.
TL;DR - You can't.
As it was slim pickings here, I sent an email over to support. Got this response:
Hello,
At this time this use case is not possible in Ninja Forms. The plugin is currently unable to transfer data from field to field or between forms.
I’m sorry that we do not have a better solution for you at this time.
Thank you,

facebook registration plugin : populating custom fields

I have an HTML form that uses the Facebook registration plugin. I have a couple of custom text fields (the kind that are included in the iFrame itself).
Whether user prefills the form using Facebook. or enters the data himself, I am able to store all values in my database without.
At the end of my post method, I redirect to load the same page. At this point, I would like to populate the fields from the data in my database. By which I mean, if the user logs off Facebook, on this page, he should still see the data that he has submitted to my database.
How do I set values for the fields (both custom and regular fields) in the registration form?
Should I say document.getElementById('field_name').value = "hello"?
Well it depends which technology you are using to generate the pages. That would be good to know. You most likely would have the JSP/ASP/PHP prepopulate those fields with from the data as it sends the HTML to the user.

Is it possible to take values of an HTML5 SessionStorage and email it?

I'm creating an application with two pages (Page One, Page Two) that have radio buttons on them. The values are stored in sessionStorage and displayed to the user on Page 3. However, I want a Submit button that will take those values in sessionStorage and email it to me (I was planning to use PHP to process and send the email). Can someone help point me in the right direction on how to solve this please?
If you already have a form with your submit button then you could have your javascript insert new inputs of type="hidden", one for each key/value pair. These values will then be submitted with the form so you can process them just like any other POST parameter.