I have a form with multiples pages. Between the first and the second page I use a page break with a condition based on a field in the first page. It’s working but I wold like to do some work on values submitted by the first page using my own function $form['#submit'][] = 'my_own_submit' before the next pages but ….. all the names of the fields was replaced with numbers ! I don’t know how I can retrieve my fields … I messed something?
In the validate function all the fields keep the name but not in submit function.
If someone can give me an idea
Thanks everyone!

Comments

quicksketch’s picture

all the names of the fields was replaced with numbers ! I don’t know how I can retrieve my fields … I messed something?

All submission values are converted to use the "component IDs" internally, since managing the data in the nested original form is technically challenging. They're all flattened to their IDs to make for easier data handling (for Webform, not for users modifying Webform).

If you want to convert from a form_key that you entered to the component ID, you can use webform_get_cid($node, $form_key), though note that form keys are not actually unique, the same form keys can be used within different fieldsets and pages.

sfcamil’s picture

Hi,

Just to say thank you for your response.
Is interesant that not all the time the formatati data is converted to id's but it's ok for moment.

Thanks

sunshinee’s picture

I know this is an older thread, but maybe it will help someone down the road. If you wanted to get all the component names and values from a given submission, you can do something like this:

<?php 
$components = array();

// Create a map with webform components by ID. 
foreach ($node->webform['components'] as $component) {
          $components[$component['cid']] = $component;
        }

// Get the text values of component keys and data
foreach ($submission->data as $cid => $component_data) {
      // get component names
      $form_key = $components[$cid]['form_key'];

      // use implode to flatten the values array
      $form_value = implode(', ', $component_data);

      //now you can do something with the form keys and values
}
?>
DanChadwick’s picture

Status: Active » Closed (works as designed)