I have a content type with 2 CCK fields. Element 1 is of type „Mapstraction CCK map“ and the second one is of type „Date“.
In the implementation ot the hook_elements() #process-Function of Mapstraction CCK there is a call to drupal_get_form(). I call this a nested form scenario.

The error occurs in the form_builder() function. This function is recursive, it calls itself for every layer of the hierarchical $form array. The problem is that form_builder() has the static variable $complete_form.

When the node form is built, there is a call to drupal_get_form() for the node form and form_builder() calls itself for every CCK field.

1.Mapstraction CCK field
When the Mapstraction CCK field is processed, form_builder() calls _form_builder_handle_input_element() and this calls the Mapstraction CCK #process function. Here the second drupal_get_form() for the nested form is started. Inside this function the static $complete_form variable is overriden and now holds a reference to the nested $form array.

2. Date CCK field
When form_builder() calls _form_builder_handle_input_element($form_id, $form, $form_state, $complete_form); for the Date CCK field,in the $complete_form parameter it passes a reference to the nested form instead of the node form. From now on things keep going from bad to worse...

Comments

martin.l’s picture

Priority: Normal » Major

Subscribing.

Isn´t this a security issue as well ?

aaron.r.carlton’s picture

Are you suggesting that you're unable to call drupal_get_form within a drupal_get_form definition? I'm not sure if it's documented whether or not this should be supported but I just ran into a similar situation.

I had a form definition calling fivestar_widget_form() which I'm sure also calls drupal_get_form. We determined that the fivestar piece was breaking the entire form, but I'm thinking the larger issue could be this 'nesting'.

subscribing!

Status: Active » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.