Form API submit handler does not get called I am using FAPI with dynamic fields. The code I am using is:

function email_action($form, &amp;$form_state) {

$result = db_query('Select * from my_action_plan_settings ORDER BY action_type');
$records = array();
foreach ($result as  $record) {
  $records[] = $record-&gt;poa;
}

for ($i = 0; $i &lt; count($records) ; $i++) {

  $form['action'] = array(
    '#type' =&gt; 'fieldset',
    '#title' =&gt; t('Action #@num', array('@num' =&gt; $i)),
    '#collapsible' =&gt; TRUE,
    '#collapsed' =&gt; FALSE,
  );

  $form['action'][$i]['poa'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('Point of Action'),
    '#default_value' =&gt; $point_of_actions[$i],
    '#description' =&gt; t("Enter first name."),
    '#required' =&gt; FALSE,
  );
  $form['action'][$i]['email'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('Email Address'),
    '#required' =&gt; FALSE,
  );

}

$form['submit'] = array(
  '#type' =&gt; 'submit',
  '#value' =&gt; 'Submit',
);

return $form;

}

function email_action_submit($form, &amp;$form_state) {
  dsm($form_state);
}


The submit handler never gets called, I used a custom submit handler also, it does not get called. If I limit the count of loop to 20, the submit handler gets called and everything works fine but without breaking the for loop, the submit handler never get called, is there a limit to number of fields? Or am I doing something wrong. Not sure what the issue is.
You can try the following :

 function email_action($form, &amp;$form_state) {

    $form['#submit'][] = 'email_action_submit';

    }


    //submit function for the form

    function email_action_submit($form, &amp;$form_state) {

    // write your submit code here
    }