1

I am using FAPI with dynamic fields. The code I am using is:

function email_action($form, &$form_state) {

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

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

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

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

}

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

return $form;

}

function email_action_submit($form, &$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.

  • Hello. Please provide your whole code, trimmed to be SSCCE. We can't begin to guess what's wrong with your hooks and handlers when we can't see their definitions. – Mołot Sep 9 '13 at 13:31
  • sorry, i have updated the code – Deepak ML Sep 9 '13 at 13:39
  • No problem. Looks better now :) – Mołot Sep 9 '13 at 13:40
  • Any errors in the dblog? Located at /admin/reports/dblog – littledynamo Sep 9 '13 at 16:09
  • no errors in dblog, i got it working, the problem is dsm, ddebug_backtrace, debug_print_backtrace, var_dump, print_r, does not get displayed on the screen, is that any server setting ? i wrote the code for db insert in submit handler and db inserts are made properly. still dont know why other functions dont display on screen. – Deepak ML Sep 9 '13 at 18:27
1

You can try the following :

 function email_action($form, &$form_state) {

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

    }


    //submit function for the form

    function email_action_submit($form, &$form_state) {

    // write your submit code here
    }
| improve this answer | |
  • thx harsh, i have tried that too, but does not get called when the entire loop is ran. works if i break in between the loop. – Deepak ML Sep 9 '13 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.