I'm using Drupal 6 to create a form that's pretty big. Basically here is how the client wants this form to act:

Users create engagements, and an engagement can have multiple goals and multiple meetings. Each goal can have multiple recommendations, and each recommendation can have multiple action steps. So far I've been able to use AHAH to dynamically add meetings and goals to engagements, but I've hit a snag as I've started to try adding recommendations to goals. I'm doing something like this for recommendations:

 $form['goals_fieldset']['goal_'.$gid]['recommendations']['rec_'.$rid]['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Recommendation Title'),
    '#default_value' => $title,

This will nest the recommendations array under the goal its attached to, my issue is, the field doesn't show up on the form, is there a limitation to how nested you can go in a form? If I use:

  $form['goals_fieldset']['goal_'.$gid]['rec_'.$rid]['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Recommendation Title'),
    '#default_value' => $title,

The field will show up. I really need the ['recommendations'] piece in there cause it is where I've set the wrapper that AHAH replaces when you click the 'add another' button:

$form['goals_fieldset']['goal_'.$gid]['recommendations'] = array(
  '#type' => 'fieldset',
  '#title' => t('Recommendations'),

  // Set up the wrapper so that AJAX will be able to replace the fieldset.
  '#prefix' => '<div id="recommendations-fieldset-wrapper">',
  '#suffix' => '</div>',

Any insight as to why my fields won't show up, or insight into how to fix is greatly appreciated. Thanks!

  • bump, could really use the help! – user2990286 Dec 10 '14 at 14:57

So I found out why its not working, very simple mistake on my part. I was declaring $form['goals_fieldset']['goal_'.$gid]['recommendations'] later in the form, erasing everything else. Sorry for wasting time!

| improve this answer | |

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.