Just want to submit field values Created a custom form, which submit values to a table.
Fields on the form created on the go.
For example if we have 5 users, we will have 5 fields, if 6 then six fields

Say if it has 5 fields

Field 01
Field 02
Field 03
Field 04
Field 05


Just want to submit all values of all fields being created on the go.

when I dsm

dsm[$form_state[values]];


It shows me array with form fields and form info like

Field 01
Field 02
Field 03
Field 04
Field 05
form_build_id
form_token
...
..


So I can't just run loop to submit all fields because 'form_build_id' etc is also there.

How can I do this dynamically?
$user_ids = array(1, 2, 3, 4, 5, 6); // This will be dynamic based on your users

foreach ($user_ids as $uid) {
  // Your form element goes here
  $form['field_user_value_' . $uid ] = array(
    // form elements
  );
}


In your submit function you have above values

$values = $form_submit['values'];

foreach ($values as $key =&gt; $values) {
  if ($substr($key, 0, 17) == "field_user_value_") {
    // Push values to database
  }
}