I'm trying to add a subform on a form by using the dynamic_subform module. Hereţs the example:

function test_form() {
  $form['some_text'] = array(
    '#type'   =>  'textfield',
    '#title'  =>  t('Some text'),
  );
  $form['button'] = array(
    '#type'   =>  'submit',
    '#value'  =>  t('Show subform'),
    '#ahah_bindings'  =>  array(
      array(
        'event'     => 'click',
        'wrapper'   => 'subform_div',
        'path'      => 'subform/add',
      ),
    ),
  );
  $form['wrapper'] = array(
    '#value' =>  '<div id="subform_div"></div>',
  );
  return $form;
}

function test_subform() {
  $form['other_text'] = array(
    '#type'   =>  'textfield',
    '#title'  =>  t('Other text'),
  );
  return $form;
}

function test_subform_add() {
  $items = dynamic_subform_get_prepped('test_form', 'test_subform', NULL);
  print theme('status_messages') . drupal_render($items);
}

Of course subform/add is handled by test_subform_add().

I got error:

No cached subform_build_id! : Can not find old cached args : Bad subform_id in args - vs test_subform

What is wrong in my implementation?

Thank you,
Claudiu

Comments

starbow’s picture

Status: Active » Closed (fixed)