5

I need to submit data to a webform.

I receive data from POST submission from mobile application ("webservices").

So I try something like :

$form_data = array();
$form_data['values']['firstname'] = $user->field_civilite['und'][0]['tid'];
$form_data['values']['lastname'] = $user->field_prenom['und'][0]['value'];
$form_data['values']['mail'] = $user->field_nom['und'][0]['value'];

webform_client_form_submit(226, $form_data);

But this is don't do anything.

Someone have any idea to do that?

3
  • Just to clarify, are you using Services?
    – Chapabu
    Nov 30, 2012 at 10:06
  • yes i'm using it Dec 3, 2012 at 11:08
  • See the solution here with a particular description how to get data into submission fields. Mar 21, 2019 at 4:24

1 Answer 1

10

webform can be programatically save, as shown in below example,

  $node = node_load($nid); //nid is the node id of your webform
  global $user;

 //the values to save
  $data = array(
    1 => array('value' => array($first_value)),
    2 => array('value' => array($second_value)),
  );

  $submission = (object) array(
    'nid' => $nid,
    'uid' => $user->uid,
    'submitted' => REQUEST_TIME,
    'remote_addr' => ip_address(),
    'is_draft' => FALSE,
    'data' => $data,
  );

  module_load_include('inc', 'webform', 'includes/webform.submissions');
  webform_submission_insert($node, $submission);
  webform_submission_send_mail($node, $submission);
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.