Hello.

I need to get the data from a submited webform, to run my own action process and save in my own tables.

Or... I need to detect a submited webform event to catch the data form the webform tables...

Thanks in advance... (Great Job)

Comments

Augusto182’s picture

Title: Get the data » Posdata

Hello. The function i want whit that is this:
(1)
* Have a form to get a code from de users
* Get the code for loguin the user as especific role
(2)
* Get parameter from user
* Make a query on db bases in that parameters

Tanks

Augusto182’s picture

Title: Posdata » How to get a data

...

Augusto182’s picture

Title: How to get a data » How to get a data for custom submit process: Webform ID

I find this: http://drupal.org/node/1291574
"Custom coding: Adding advanced validation or submit code" D6 version

/**
 * Implementation of hook_form_alter().
 */
function mywebform_extra_form_alter(&$form, &$form_state, $form_id) {
  // Add validation for a particular Webform node:
  if ($form_id == 'webform_client_form_44') {
    // Simply add the additional validate handler.
    $form['#validate'][] = 'mywebform_extra_validate_44';

    // Add the submit handler after the existing Webform submit handler,
    // but before the second Webform handler. Pop off the first one and add
    // ours second.
    $first = array_shift($form['#submit']);
    array_unshift($form['#submit'], $first, 'mywebform_extra_submit_44');
  }
}

/**
 * Validation handler for Webform ID #44.
 */
function mywebform_extra_validate_44($form, $form_state) {
  global $user;
  if (!isset($user->roles[4])) {
    form_set_error('', t('Your user role is not allowed to submit this Webform.'));
  }
}

/**
 * Submit handler for Webform ID #44.
 */
function mywebform_extra_submit_44($form, $form_state) {
  global $user;

  // Changes can be made to the Webform node settings by modifying this variable:
  $form['#node']->webform;

  // Insert things into other database tables or modify properties.
}

My question is: The Webform ID is the same id webform node?

And... this code aply to D7 version?

quicksketch’s picture

Category: feature » support
Priority: Critical » Normal
Status: Active » Closed (fixed)

My question is: The Webform ID is the same id webform node?

And... this code aply to D7 version?

Yes to both.

As mentioned in the submission guidelines, I don't provide help with custom coding:

Any issues regarding "how do I code ..." or "how do I theme ..." will not be answered. Please look elsewhere for coding resources.

Please refer to other resources such as IRC or Drupal StackExchange to ask your questions.

Augusto182’s picture

It works.

This info will be usefull...

Bye

garglalit0’s picture

To get the webform submission id in custom form handler

function MODULE_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id)
{
if($form_id== 'webform_submission_add_form')
{
$form['actions']['submit']['#submit'][] = 'MODULE_custom_submit_handler';
}
}

function MODULE_custom_submit_handler(&$form, \Drupal\Core\Form\FormStateInterface $form_state)
{
$webform_submission_id = $form_state->getFormObject()->getEntity()->id();
kint($webform_submission_id );
}

hope this help to get the Webform submission id in custom handler form of webform.

This fix my problem.