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).

1
  • 3
    showing your code would help Commented Jul 12, 2012 at 14:29

2 Answers 2

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');

1
  • 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. Commented Aug 21, 2014 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 :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.