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
Comment #1
martin.l commentedSubscribing.
Isn´t this a security issue as well ?
Comment #2
aaron.r.carlton commentedAre 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!