Zh GoogleMap RSForm: Difference between revisions

From Documentation
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 34: Line 34:
1 - in Form properties, Section PHP Scripts, I added parsing '''Where''' field. In part '''Script''' called after form has been processed added this code
1 - in Form properties, Section PHP Scripts, I added parsing '''Where''' field. In part '''Script''' called after form has been processed added this code


<nowiki>
<code>
foreach($mappings as $mapping)
foreach($mappings as $mapping)
{
{
Line 47: Line 47:
   $mapping->data = serialize($data);
   $mapping->data = serialize($data);
}
}
</nowiki>
</code>

Revision as of 12:08, 6 March 2017

Before this time I didn't use forms, created by RSForm.


In February 2017, user of my extension Phillip ask me to help with integration with RSForm! Pro.


I checked RSFrom docs and tutorials and understand that it is very easy.


This forms can do insert into any your database tables. And I store all data in tables.


The main task was - create placemark from filled form fields.


Lets do that.


First of all you have to configure your form, and create map field.


Look at image, the field Where is store position on map.


After that lets go to see how it is displayed on site.


Now lets come back to form configuration and do the integration.

1 - in Form properties, Section PHP Scripts, I added parsing Where field. In part Script called after form has been processed added this code

foreach($mappings as $mapping) {

 $data = unserialize($mapping->data);
 $coords = explode(",", $_POST['form']['Where']); 
 $lat = $coords[0];
 $lng = $coords[1];
 $data["latitude"] = strip_tags($lat);
 $data["longitude"] = strip_tags($lng);
 $mapping->data = serialize($data);

}