Batching with Google Places: Is it possible? - google-maps-api-3

I was wondering if it's possible to send batched requests to maps.googleapis.com. As far as I can tell, it isn't.
I was using the Google API Client Library with supports batching, but it's only for www.googleapis.com. I went ahead and hacked it so that I could call the Places API, and it worked fine for normal calls, but when I actually tried to batch them, I got a 404 error:
"The requested URL /batch was not found on this server. That’s all we know."
So it appears that maps.googleapis.com does not support batching, but I wanted to be sure this is true. If anyone knows otherwise, please tell me how. Thanks!
inside google-api-php-client/src/Google/Config.php:
- 'base_path' => 'https://www.googleapis.com',
+ 'base_path' => 'https://maps.googleapis.com',
google-api-php-client/src/Google/Service/Maps.php:
(I added this file to make Places calls possible.)
<?php
class Google_Service_Maps extends Google_Service
{
const MAPS = "https://maps.googleapis.com/auth/maps";
public function __construct(Google_Client $client)
{
parent::__construct($client);
$this->servicePath = 'maps/api/';
$this->version = 'v3';
$this->serviceName = 'maps';
$this->places = new Google_Service_Maps_Places_Resource(
$this,
$this->serviceName,
'places',
array(
'methods' => array(
'autocomplete' => array(
'path' => 'place/autocomplete/json',
'httpMethod' => 'GET',
'parameters' => array(
'input' => array(
'location' => 'query',
'type' => 'string',
'required' => true,
),
'sensor' => array(
'location' => 'query',
'type' => 'boolean',
'required' => true,
),
'location' => array(
'location' => 'query',
'type' => 'string',
),
'radius' => array(
'location' => 'query',
'type' => 'integer',
),
),
),
)
)
);
}
}
class Google_Service_Maps_Places_Resource extends Google_Service_Resource
{
public function autocomplete($input, $lat, $lng, $radius, $optParams = array())
{
$params = array('input' => $input, 'location' => "$lat,$lng", 'radius' => $radius, 'sensor' => false);
$params = array_merge($params, $optParams);
return $this->call('autocomplete', array($params));
}
}
API batch calling code:
<?php
const API_KEY = 'MY_API_KEY';
set_include_path("google-api-php-client/src/" . PATH_SEPARATOR . get_include_path());
require_once 'Google/Client.php';
require_once 'Google/Service/Maps.php';
require_once 'Google/Http/Batch.php';
$client = new Google_Client();
$client->setApplicationName("Client_Library_Examples");
$client->setDeveloperKey(API_KEY);
$client->setUseBatch(true);
$batch = new Google_Http_Batch($client);
$service = new Google_Service_Maps($client);
$inputs = array(
'Dolore',
'MacAl',
'App Aca'
);
foreach($inputs as $input) {
$req = $service->places->autocomplete($input, 37.7833, -122.4167, 500);
$batch->add($req, $input);
}
$results = $batch->execute();
print_r($results);
print_r($req);

Related

How to redirect after view rendering is complete in cakephp 2.3

I am using cakephp 2.3 and required to redirect user after the excel sheet is downloaded successfully. I am using the cake $this->response->type for setting the view as excel sheet generator.
public function admin_export_excel($task_lists = array()) {
$task_ids = $task_lists;
$global_task_array = array();
$this->loadModel('Task');
//-> For each task-id run the loop for fetching the related data to generate the report.
foreach ($task_ids as $index => $task_id) {
//-> Check if the task exists with the specified id.
$this->Task->id = $task_id;
if (!$this->Task->exists())
throw new NotFoundException('Task not found.');
//-> Now check if the logged user is the owner of the specified task.
$task_count = $this->Task->find('count', array('conditions' => array('Task.id' => $task_id,
'Task.user_id' => $this->Auth->user('id'))));
if ($task_count == 0)
throw new NotFoundException('Task not accessable.');
$task_data = $this->Task->find('first', array(
'conditions' => array(
'Task.id' => $task_id
),
'contain' => array(
'TaskForm' => array(
'fields' => array('TaskForm.id', 'TaskForm.reference_table')
),
'Project' => array(
'fields' => array('Project.id', 'Project.project_name')
),
'User' => array(
'fields' => array('User.id', 'User.company_name')
),
'Timezone' => array(
'fields' => array('Timezone.id', 'Timezone.name')
)
)
)
);
// debug($task_data);
$global_task_array[$index] = $task_data;
//-> End of Custom else conditions
unset($task_data);
}
$this->set('global_task_array', $global_task_array);
$this->response->type(array('xls' => 'application/vnd.ms-excel'));
$this->response->type('xls');
$this->render('admin_export_excel');
}
and my view file is
$this->PhpExcel->createWorksheet();
$this->PhpExcel->setDefaultFont('Calibri', 13);
$default = array(
array('label' => __('Task Id'), 'width' => 'auto'),
array('label' => __('Unique Code'), 'width' => 'auto'),
array('label' => __('Site Name'), 'width' => 'auto'),
array('label' => __('Area'), 'width' => 'auto'),
array('label' => __('Location'), 'width' => 'auto'),
array('label' => __('Sub Location'), 'width' => 'auto'),
array('label' => __('About Task'), 'width' => 'auto')
);
$this->PhpExcel->addTableHeader($default, array('name' => 'Cambria', 'bold' => true));
$this->PhpExcel->setDefaultFont('Calibri', 12);
foreach ($global_task_array as $index => $raw) {
$data = array(
$raw['Task']['id'],
$raw['Task']['unique_code'],
$raw['Task']['site_name'],
$raw['Task']['area'],
$raw['Task']['location'],
$raw['Task']['sub_location'],
$raw['Task']['about_task']
);
$this->PhpExcel->addTableRow($data);
}
$this->PhpExcel->addTableFooter();
$this->PhpExcel->output('Task-' . date('d-m-Y') . '.xlsx');
I have tried to use the cake afterFilter method for to redirect the user to other action after the excel sheet is generated but its not working.
public function afterFilter(){
parent::afterFilter();
if($this->request->params['action'] == 'admin_export_excel'){
$this->redirect(array('controller' => 'tasks', 'action' => 'index','admin' => true));
}
}
Any help will be appreciated. Thanks

how to load database content to dropdown options (select)

i'm still working on my own drupal 7 module, and i'm having some trouble. I'm trying to load database content to dropdown option (select), i have read and write the same code from drupal example, but my database still not loading, only empty option.
what i'm asking is there anything wrong on my code or is there any faster way to load database to dropdown option other than the drupal example???
here the code i'm working on
function prod_entry_load($entry = array()) {
$select = db_select('aa_1122','aa');
$select->fields('aa');
foreach ($entry as $field => $value) {
$select->condition($field, $value);
}
return $select->execute()->fetchAll();
}
function prod(){
return drupal_get_form('prod_form');
}
function prod_form($form_state){
$form = array(
'#prefix' => '<div id="updateform">',
'#suffix' => '</div>',
);
$entries = prod_entry_load();
$keyed_entries = array();
if (empty($entries)) {
$form['no_values'] = array(
'#value' => t("No entries exist in the table dbtng_example table."),
);
return $form;
}
foreach ($entries as $entry) {
$options[$entry->no] = t("#no: #name ", array('#no' => $entry->no, '#name' => $entry->name));
$keyed_entries[$entry->no] = $entry;
}
$default_entry = !empty($form_state['values']['no']) ? $keyed_entries[$form_state['values']['no']] : $entries[0];
$form_state['entries'] = $keyed_entries;
$form['no'] = array(
'#type' => 'select',
'#title' => t('Choose'),
'#default_value' => $default_entry->no,
'#ajax' => array(
'wrapper' => 'updateform',
'callback' => 'prod_form_update_callback',
),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
'#ajax' => array(
'callback' => 'ajax_alert',
),
);
return $form;
}
function prod_form_update_callback($form, $form_state) {
$entry = $form_state['entries'][$form_state['values']['no']];
foreach (array('name') as $item) {
$form[$item]['#value'] = $entry->$item;
}
return $form;
}
You've just forgotten to add the #options key to your select element, the code should read like this:
$form['no'] = array(
'#type' => 'select',
'#title' => t('Choose'),
'#default_value' => $default_entry->no,
'#options' => $options, // This is the bit that was missing
'#ajax' => array(
'wrapper' => 'updateform',
'callback' => 'prod_form_update_callback',
),
);
You could shorten your query/options code slightly using a combination of string concatenation in MySQL and the db fetchAllKeyed() method:
$query = db_select('aa_1122', 'aa')->fields('aa', array('no'));
$query->addExpression("CONCAT(no, ': ', name)", 'display');
$options = $query->execute()->fetchAllKeyed();

How To Create New Content Type Programmatically in Drupal 7?

I'm building a module (my_module) in Drupal 7.
It has some functionality and also will create new content type.
In my_module.install I implemented the hook_install (my_module_install).
Can I use more one implementation of hook_install to create new content type (my_cck_install) in this module?
If (yes), how should I do this?
Else: have I do this in another module? :-)
You can't use more than one implementation of hook_install in the same module; in PHP you can't have 2 function with the same name which rules this out.
You would just need to add your new content type in the same hook_install anyway (have a look at how the standard installation profile does it at /profiles/standard/standard.install). This is how I always add new content types from the install file (using the example of a testimonials module):
function testimonial_install() {
// Make sure a testimonial content type doesn't already exist
if (!in_array('testimonial', node_type_get_names())) {
$type = array(
'type' => 'testimonial',
'name' => st('Testimonial'),
'base' => 'node_content',
'custom' => 1,
'modified' => 1,
'locked' => 0,
'title_label' => 'Customer / Client Name'
);
$type = node_type_set_defaults($type);
node_type_save($type);
node_add_body_field($type);
}
}
The following code will create a content type called "Event" with a machine name of 'event' and a title field -
//CREATE NEW CONTENT TYPE
function orderform_node_info() {
return array(
'event' => array(
'name' => t('Event'),
'base' => 'event',
'description' => t('A event content type'),
'has_title' => TRUE
),
);
}
function event_form($node,$form_state) {
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('event Title'),
'#default_value' => !empty($node->title) ? $node->title : '',
'#required' => TRUE,
'#weight' => -5
);
return $form;
}
//END CONTENT TYPE
you should place it in your .module file... if you want do add additional fields to it, let me know and I'll patch you up with the code... good luck!
/**
* Implements hook_node_info()
*/
function mymodule_node_info() {
return array(
'news' => array(
'name' => t('News'),
'base' => 'news',
'description' => t('You can add News here'),
'has_title' => TRUE,
'title_label' => t('News title')
)
);
}
/**
* Implement hook_form()
*/
function mymodule_form($node, $form_state) {
return node_content_form($node, $form_state);
}
Add the implementation to mymodule.install is as follows:
/**
* Implements hook_install().
*/
function mymodule_install() {
node_types_rebuild();
$types = node_type_get_types();|
node_add_body_field($types['news']);
}
You can get a detailed description with code from here
/*
* Implementation in hook node info in .Module file
*/
function test_node_info() {
return array(
'product' => array(
'name' => t('Product'),
'base' => 'product',
'description' => t('Product Title'),
)
);
}
/**
* Implement hook_form()
*/
function product_form($node, $form_state) {
return node_content_form($node, $form_state);
}
/**
* Implements hook_install() in .install file.
*/
function test_install() {
node_types_rebuild();
$types = node_type_get_types();
node_add_body_field($types['product']);
//New way to implement to add fields in your content type
foreach (_test_installed_fields() as $field) {
field_create_field($field);
}
foreach (_test_installed_instances() as $fieldinstance) {
$fieldinstance['entity_type'] = 'node';
$fieldinstance['bundle'] = 'product';
field_create_instance($fieldinstance);
}
}
/*
* Define your fields
*/
function _test_installed_fields() {
$t = get_t();
return array(
'product_title123' => array(
'field_name' => 'product_title123',
'label' => $t('Product Title'),
'type' => 'text'
),
'description123' => array(
'field_name' => 'description123',
'label' => $t('Description'),
'type' => 'text'
),
);
}
/*
* Define your instance of fields
*/
function _test_installed_instances() {
$t = get_t();
return array(
'product_title123' => array(
'field_name' => 'product_title123',
'type' => 'text',
'label' => $t('Product Title'),
'widget' => array(
'type' => 'text_textfield'
),
'display' => array(
'example_node_list' => array(
'label' => $t('Product Title'),
'type' => 'text'
)
)
),
'description123' => array(
'field_name' => 'description123',
'type' => 'text',
'label' => $t('Description'),
'widget' => array(
'type' => 'text_textarea_with_summary'
),
'display' => array(
'example_node_list' => array(
'label' => $t('Description'),
'type' => 'text'
)
)
),
);
}
/**
* Implements hook_uninstall().
*/
function test_uninstall() {
$ournewtype = 'product';
$sql = 'SELECT nid FROM {node} n WHERE n.type = :type';
$result = db_query($sql, array(':type' => $ournewtype));
$nodeids = array();
foreach ($result as $row) {
$nodeids[] = $row->nid;
}
node_delete_multiple($nodeids);
node_type_delete($ournewtype);
}
That's it.

Drupal module function theming with ahah

My main question is:
Does the theme_hook() function gets called whenever the form gets rebuilt via ahah (ahah_helper) ?
I'm trying to show a select box, with some filtering options, when the user changes it, the table below it changes too.
I have this by now:
function veiculos_listar_form($form_state)
{
$form = array();
ahah_helper_register($form, $form_state);
//biulds $options
$form['listar_veics'] = array(
'#type' => 'fieldset',
'#prefix' => '<div id="listar-veics-wrapper">',
'#suffix' => '</div>',
'#tree' => TRUE,
);
if (!isset($form_state['values']['listar_veics']['filial']))
$form['#filial_veic'] = 1;
else
$form['#filial_veic'] = $form_state['values']['listar_veics']['filial'];
$form['listar_veics']['filial'] = array(
'#type' => 'select',
'#title' => "Listar veículos da filial",
'#options' => $filiais,
'#default_value' => $form['#filial_veic'],
'#ahah' => array(
'event' => 'change',
'path' => ahah_helper_path(array('listar_veics')),
'wrapper' => 'listar-veics-wrapper',
'method' => 'replace',
),
);
return $form;
}
function veiculos_listar_form_submit($form, &$form_state)
{
}
function _listar_veiculos_tabela($filial)
{
//builds $header and $data
$table = theme_table($header, $data);
return $table;
}
function theme_veiculos_listar_form($form)
{
$output = drupal_render($form);
$filial = $form['#filial_veic'];
$output .= '<br>' . $filial . '<br>';
$output .= _listar_veiculos_tabela($filial);
return $output;
}
function veiculos_theme() {
return array(
'veiculos_listar_form' => array(
'arguments' => array('form' => NULL),),
);
}
In my little and innocent world, it should work if theme_hook is called on every ahah event (change).
The problem is, the variable printed is always the same, like what the user is choosing isn't being stored. If the user select a different options, it shows the new option, but the $filial variable is always the same when the theme prints.
Like this:
http://img230.imageshack.us/img230/9646/62144334.jpg
Any suggestion on what i could do to make this work? I'm developing our own module, so using views module isn't a good idea.
Thanks.
You should redo code this way.
Ahah callback I do not wrote, I think you would not have problem with it.
Check some examples on drupal.org
function veiculos_listar_form($form_state)
{
$form = array();
ahah_helper_register($form, $form_state);
//biulds $options
// remove divs because we do not want to reload selector with ahah
$form['listar_veics'] = array(
'#type' => 'fieldset',
'#tree' => TRUE,
);
if (!isset($form_state['values']['listar_veics']['filial']))
$form['#filial_veic'] = 1;
else
$form['#filial_veic'] = $form_state['values']['listar_veics']['filial'];
// add cover div here, because we will reload table
$form['table'] = array(
'#prefix' => '<div id="listar-veics-wrapper">',
'#suffix' => '</div>',
'#type' => 'markup',
'#value' => _listar_veiculos_tabela($form['#filial_veic']),
);
$form['listar_veics']['filial'] = array(
'#type' => 'select',
'#title' => "Listar veículos da filial",
'#options' => $filiais,
'#default_value' => $form['#filial_veic'],
'#ahah' => array(
'event' => 'change',
'path' => ahah_helper_path(array('listar_veics')),
'wrapper' => 'listar-veics-wrapper',
'method' => 'replace',
),
);
return $form;
}
function veiculos_listar_form_submit($form, &$form_state)
{
}
function _listar_veiculos_tabela($filial)
{
//builds $header and $data
$table = theme_table($header, $data);
return $table;
}
function theme_veiculos_listar_form($form)
{
$output = drupal_render($form);
return $output;
}
function veiculos_theme() {
return array(
'veiculos_listar_form' => array(
'arguments' => array('form' => NULL),),
);
}

Drupal Ctools Form Wizard in a Block

I created a custom module that has a Ctools multi step form. It's basically a copy of http://www.nicklewis.org/using-chaos-tools-form-wizard-build-multistep-forms-drupal-6.
The form works. I can see it if I got to the url i made for it.
For the life of me I can't get the multistep form to show up in a block.
Any clues?
/**
* Implementation of hook_block()
* */
function mycrazymodule_block($op='list', $delta=0, $edit=array()) {
switch ($op) {
case 'list':
$blocks[0]['info'] = t('SFT Getting Started');
$blocks[1]['info'] = t('SFT Contact US');
$blocks[2]['info'] = t('SFT News Letter');
return $blocks;
case 'view':
switch ($delta){
case '0':
$block['subject'] = t('SFT Getting Started Subject');
$block['content'] = mycrazymodule_wizard();
break;
case '1':
$block['subject'] = t('SFT Contact US Subject');
$block['content'] = t('SFT Contact US content');
break;
case '2':
$block['subject'] = t('SFT News Letter Subject');
$block['content'] = t('SFT News Letter cONTENT');
break;
}
return $block;
}
}
/**
* Implementation of hook_menu().
*/
function mycrazymodule_menu() {
$items['hellocowboy'] = array(
'title' => 'Two Step Form',
'page callback' => 'mycrazymodule_wizard',
'access arguments' => array('access content')
);
return $items;
}
/**
* menu callback for the multistep form
* step is whatever arg one is -- and will refer to the keys listed in
* $form_info['order'], and $form_info['forms'] arrays
*/
function mycrazymodule_wizard() {
$step = arg(1);
// required includes for wizard
$form_state = array();
ctools_include('wizard');
ctools_include('object-cache');
// The array that will hold the two forms and their options
$form_info = array(
'id' => 'getting_started',
'path' => "hellocowboy/%step",
'show trail' => FALSE,
'show back' => FALSE,
'show cancel' => false,
'show return' =>false,
'next text' => 'Submit',
'next callback' => 'getting_started_add_subtask_next',
'finish callback' => 'getting_started_add_subtask_finish',
'return callback' => 'getting_started_add_subtask_finish',
'order' => array(
'basic' => t('Step 1: Basic Info'),
'lecture' => t('Step 2: Choose Lecture'),
),
'forms' => array(
'basic' => array(
'form id' => 'basic_info_form'
),
'lecture' => array(
'form id' => 'choose_lecture_form'
),
),
);
$form_state = array(
'cache name' => NULL,
);
// no matter the step, you will load your values from the callback page
$getstart = getting_started_get_page_cache(NULL);
if (!$getstart) {
// set form to first step -- we have no data
$step = current(array_keys($form_info['order']));
$getstart = new stdClass();
//create cache
ctools_object_cache_set('getting_started', $form_state['cache name'], $getstart);
//print_r($getstart);
}
//THIS IS WHERE WILL STORE ALL FORM DATA
$form_state['getting_started_obj'] = $getstart;
// and this is the witchcraft that makes it work
$output = ctools_wizard_multistep_form($form_info, $step, $form_state);
return $output;
}
function basic_info_form(&$form, &$form_state){
$getstart = &$form_state['getting_started_obj'];
$form['firstname'] = array(
'#weight' => '0',
'#type' => 'textfield',
'#title' => t('firstname'),
'#size' => 60,
'#maxlength' => 255,
'#required' => TRUE,
);
$form['lastname'] = array(
'#weight' => '1',
'#type' => 'textfield',
'#title' => t('lastname'),
'#required' => TRUE,
'#size' => 60,
'#maxlength' => 255,
);
$form['phone'] = array(
'#weight' => '2',
'#type' => 'textfield',
'#title' => t('phone'),
'#required' => TRUE,
'#size' => 60,
'#maxlength' => 255,
);
$form['email'] = array(
'#weight' => '3',
'#type' => 'textfield',
'#title' => t('email'),
'#required' => TRUE,
'#size' => 60,
'#maxlength' => 255,
);
$form['newsletter'] = array(
'#weight' => '4',
'#type' => 'checkbox',
'#title' => t('I would like to receive the newsletter'),
'#required' => TRUE,
'#return_value' => 1,
'#default_value' => 1,
);
$form_state['no buttons'] = TRUE;
}
function basic_info_form_validate(&$form, &$form_state){
$email = $form_state['values']['email'];
$phone = $form_state['values']['phone'];
if(valid_email_address($email) != TRUE){
form_set_error('Dude you have an error', t('Where is your email?'));
}
//if (strlen($phone) > 0 && !ereg('^[0-9]{1,3}-[0-9]{3}-[0-9]{3,4}-[0-9]{3,4}$',
$phone)) {
//form_set_error('Dude the phone', t('Phone number must be in format xxx-xxx-
nnnn-nnnn.'));
//}
}
function basic_info_form_submit(&$form, &$form_state){
//Grab the variables
$firstname =check_plain ($form_state['values']['firstname']);
$lastname = check_plain ($form_state['values']['lastname']);
$email = check_plain ($form_state['values']['email']);
$phone = check_plain ($form_state['values']['phone']);
$newsletter = $form_state['values']['newsletter'];
//Send the form and Grab the lead id
$leadid = send_first_form($lastname, $firstname, $email,$phone, $newsletter);
//Put into form
$form_state['getting_started_obj']->firstname = $firstname;
$form_state['getting_started_obj']->lastname = $lastname;
$form_state['getting_started_obj']->email = $email;
$form_state['getting_started_obj']->phone = $phone;
$form_state['getting_started_obj']->newsletter = $newsletter;
$form_state['getting_started_obj']->leadid = $leadid;
}
function choose_lecture_form(&$form, &$form_state){
$one = 'event 1'
$two = 'event 2'
$three = 'event 3'
$getstart = &$form_state['getting_started_obj'];
$form['lecture'] = array(
'#weight' => '5',
'#default_value' => 'two',
'#options' => array(
'one' => $one,
'two' => $two,
'three' => $three,
),
'#type' => 'radios',
'#title' => t('Select Workshop'),
'#required' => TRUE,
);
$form['attendees'] = array(
'#weight' => '6',
'#default_value' => 'one',
'#options' => array(
'one' => t('I will be arriving alone'),
'two' =>t('I will be arriving with a guest'),
),
'#type' => 'radios',
'#title' => t('Attendees'),
'#required' => TRUE,
);
$form_state['no buttons'] = TRUE;
}
/**
* Same idea as previous steps submit
*
*/
function choose_lecture_form_submit(&$form, &$form_state) {
$workshop = $form_state['values']['lecture'];
$leadid = $form_state['getting_started_obj']->leadid;
$attendees = $form_state['values']['attendees'];
$form_state['getting_started_obj']->lecture = $workshop;
$form_state['getting_started_obj']->attendees = $attendees;
send_second_form($workshop, $attendees, $leadid);
}
//----PART 3 CTOOLS CALLBACKS -- these usually don't have to be very unique
/**
* Callback generated when the add page process is finished.
* this is where you'd normally save.
*/
function getting_started_add_subtask_finish(&$form_state) {
dpm($form_state);
$getstart = &$form_state['getting_started_obj'];
drupal_set_message('mycrazymodule '.$getstart->name.' successfully deployed' );
//Get id
// Clear the cache
ctools_object_cache_clear('getting_started', $form_state['cache name']);
$form_state['redirect'] = 'hellocowboy';
}
/**
* Callback for the proceed step
*
*/
function getting_started_add_subtask_next(&$form_state) {
dpm($form_state);
$getstart = &$form_state['getting_started_obj'];
$cache = ctools_object_cache_set('getting_started', $form_state['cache name'],
$getstart);
}
//PART 4 CTOOLS FORM STORAGE HANDLERS -- these usually don't have to be very unique
/**
* Remove an item from the object cache.
*/
function getting_started_clear_page_cache($name) {
ctools_object_cache_clear('getting_started', $name);
}
/**
* Get the cached changes to a given task handler.
*/
function getting_started_get_page_cache($name) {
$cache = ctools_object_cache_get('getting_started', $name);
return $cache;
}
//Salesforce Functions
function send_first_form($lastname, $firstname,$email,$phone, $newsletter){
$send = array("LastName" => $lastname , "FirstName" => $firstname, "Email" => $email
,"Phone" => $phone , "Newsletter__c" =>$newsletter );
$sf = salesforce_api_connect();
$response = $sf->client->create(array($send), 'Lead');
dpm($response);
return $response->id;
}
function send_second_form($workshop, $attendees, $leadid){
$send = array("Id" => $leadid , "Number_Of_Pepole__c" => "2" );
$sf = salesforce_api_connect();
$response = $sf->client->update(array($send), 'Lead');
dpm($response, 'the final response');
return $response->id;
}
Am assuming you have enabled the block from admin. To do a quick check that the block is indeed getting rendered on the page you are looking at, try returning a test string along with your rendered form, from your block callback.
If that doesn't work, try clearing your cache from admin/settings/performance and try again. If I am not wrong, blocks are cached by default. Let us see if it shows up then.

Resources