2

I have tried to set up an online example of a form using Drupal 7.

When I run it, the radio buttons do not show at all.
I also get the following errors:

Notice: Undefined index: #title_display in form_pre_render_conditional_form_element() (line 3090 of /var/www/sandbox7/includes/form.inc).
Notice: Undefined index: #title_display in form_pre_render_conditional_form_element() (line 3090 of /var/www/sandbox7/includes/form.inc).
Notice: Undefined index: #id in drupal_process_states() (line 4549 of /var/www/sandbox7/includes/common.inc).
Notice: Undefined index: #id in drupal_process_states() (line 4549 of /var/www/sandbox7/includes/common.inc).
Notice: Undefined index: #id in drupal_process_states() (line 4549 of /var/www/sandbox7/includes/common.inc).

  • 3
    showing your code would help – Jimajamma Jul 12 '12 at 14:29
6

Is the form running through drupal_get_form? This type of error can occur when using the generic render() fuction on a form that hasn't been prepared by drupal_get_form(). Check your hook_menu settings and make sure your page callback is set to drupal_get_form() with the form id as the page arguments(encapsulated in an array)

if you must use a custom page callback, make sure that you're piping the form based output through drupal_get_form() like so...

$output = drupal_get_form('form_id');

  • pure genius! I never would have solved this without your help! tyvm. This is a very useful piece of info to be able to find instead of having to discover for yourself. – DrCord Aug 21 '14 at 17:34
0

ok the correct form for do it this is this

   $items['examples/form_example/states'] = array(
    'title' => '#states example',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('form_example_states_form'),
    'access callback' => TRUE,
    'description' => 'How to use the #states attribute in FAPI',
    'file' => 'form_example_states.inc',
  );

the wrong form is this

   $items['examples/form_example/states'] = array(
    'title' => '#states example',
    'page callback' => 'form_example_states_form',
    'access callback' => TRUE,
    'description' => 'How to use the #states attribute in FAPI',
    'file' => 'form_example_states.inc',
  );

and working :)

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.