Extracting field values (of certain entity type and bundle) from form/form_state I have fields of entity type foo and bundle name bar. These fields get rendered as an HTML input inside a form. There are other fields present on the form, but I'm only interested in foo/bar ones.

The number of foo/bar fields is dynamic (as are the names). I need a way to extract their name/value pairs.

Here's my situation in code:

function submit($form, &amp;$form_state) {
  // Get all the submitted data that is backed by a field of
  // an entity type 'foo' and bundle 'bar'
}


Thanks.
All the field values are in $form_state['values']. See: drupal_form_submit.

You might also be interested in using hook_form_BASE_FORM_ID_alter instead of hook_form_alter to target a particular content type. Your function would look like: 'mymodule_form_' . $form_id . '_alter'.

Or at least an:

if ($form_id == 'your_content_type') { // add new submit handler }


in hook_form_alter.

Also use LANGUAGE_NONE, without quotes, instead of 'und' ie $some-&gt;var[LANGUAGE_NONE]['value'];



Also for future reference: 
Install the Devel module, use dpm($form_state,'$form_state');

When you use dpm you get nice dumps of variables that look like:
http://goo.gl/qIf6p